Share via

Correct syntax for ForEach to modify MailboxFolderPermissions

IMK 586 Reputation points
2021-08-24T13:41:11.857+00:00

Hi

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?

Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kai Yao 37,786 Reputation points Moderator
    2021-08-25T02:52:44.697+00:00

    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.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.