0
votes

What I need to do is grant one user read access to the whole business exchange calendars. So I’ll need to loop through or create an array of all users using powershell in Exchange. What’s the best way? Something like the below, but this may be completely wrong.

Please advise! I need to run this from exchange server as the command in the loop is specific to exchange.

$Users = Get-ADGroupMember -Identity $name | Where-Object {$_.distinguishedName -like 'OU=Depots'}

foreach ($user in $users) {
Add-MailboxFolderPermission -Identity $user:\ -User USERABC-AccessRights Reviewer Add-MailboxFolderPermission -Identity $user:\Calendar -User USERABC -AccessRights Reviewer

}

2

2 Answers

1
votes

-Like is a wildcard match operator, so you're going to need to include the '*' fore and aft or it's not going to match anything.

$Users = Get-ADGroupMember -Identity $name | Where-Object {$_.distinguishedName -like '*OU=Depots*'}
0
votes

The solution is:

$mbxs = Get-Mailbox

foreach ($mbx in $mbxs) {

    Add-MailboxFolderPermission -Identity "$($mbx.Alias):\Calendar" -User USERABC -AccessRights Reviewer

}