Link to home
Start Free TrialLog in
Avatar of fuzzyfreak
fuzzyfreak

asked on

How do I add multiple users to a Powershell command so that they have access to a calendar on a mailbox?

I have the command I need to add one user to my calendar -
Add-MailboxFolderPermission John:\calendar  -AccessRight PublishingEditor -User Suzan 

Open in new window


But what if, in addition to Suzan, I want Patrick, Adrian and Paul?

thanks
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

[array]$Users = @("Suzan","Patrick","Adrian","Paul")
foreach ($User in $Users)
{
Add-MailboxFolderPermission John:\calendar  -AccessRight PublishingEditor -User $User
}
Avatar of fuzzyfreak
fuzzyfreak

ASKER

Justin, can you please put the code tags around this because the spaces are confusing me - I tried the code without the spaces and it doesn't like various parts such as 'foreach' and 'in' and '(' and ')'

thanks
[array]$Users = @("Suzan","Patrick","Adrian","Paul")
 foreach ($User in $Users)
 {
 Add-MailboxFolderPermission John:\calendar  -AccessRight PublishingEditor -User $User
 } 

Open in new window

Thanks I'll give this a go once back in the office.
Justin, thank you very much, this worked perfectly!

I now wish to apply this to multiple mailboxes, I tried adjusting that script to simply add the additional one underneath but this did not work, see below for example -

[array]$Users = @("Suzan","Patrick","Adrian","Paul")
 foreach ($User in $Users)
 { Add-MailboxFolderPermission John:\calendar  -AccessRight PublishingEditor -User $User }
 { Add-MailboxFolderPermission alan:\calendar  -AccessRight PublishingEditor -User $User } 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is perfect, worked like a dream.

thank you very much!
Excellent solution!