Correct syntax for ForEach to modify MailboxFolderPermissions

IMK 421 Reputation points


I have a mail-enabled security group, named "MESGroup", with about 15 users.

I want to modify Calendar permissions for these users. Let's say that I want to set Default users AccessRights to Reviewer to all members of my MESGroup.

This is some ForEach PowerShell syntax but what is the correct syntax to do this?

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,254 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao-MSFT 37,576 Reputation points Microsoft Vendor

    Hi @IMK

    You may use the following script to get all user mailboxes and assign Reviewer permission of the calendar folder to the security group:

    $users = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox  
    Foreach($user in $users)  
    	Add-MailboxFolderPermission -Identity $User":\Calendar" -User <SecurityGroup> -AccessRights Reviewer  

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.