Adding calendar permissions to new user creation?

I use the following script for new user creation:

$first = Read-Host "First Name" $last = Read-Host "Last Name" $loginid = ($first.SubString(0,1)).ToLower() + $last.ToLower() $upn = "$loginid@domain.com" New-Mailbox -Name "$first $last" -UserPrincipalName $upn -Password (ConvertTo-SecureString -String 'crappypassword' -AsPlainText -Force) -FirstName $first -LastName $last -database db3 Add-ADGroupMember -Identity "group1" -Members $loginid Add-ADGroupMember -Identity "group2" -Members $loginid 

I’d like to add something like the following into my script

Add-MailboxFolderPermission -identity “Managingdirector:Calendar” -user “personalassistant” -AccessRights Reviewer 

Except I’m a noob at this and don’t know how to replace the explicitly defined username with the one relative to the account being created.

submitted by /u/InvalidBootDevice
[link] [comments]

Leave a Reply