Is it possible to achieve this for multiple users CSV import etc.

I have used the following for individual accounts before but not sure how to apply it to multiple accounts

Remove-MailboxPermission -Identity Sharedmailbox -User USER -AccessRights FullAccess,SendAs,ExternalAccount,DeleteItem,ReadPermission,ChangePermission,ChangeOwner -InheritanceType All 

Also is there a way to revert this if needed so basically adding all the same users with a Script

Thanks in advance

1

There are 1 answers

0
KKI On

You need to get all permission first with Get-Mailboxpermission command.

https://learn.microsoft.com/en-us/powershell/module/exchange/get-mailboxpermission?view=exchange-ps

After it, you can iterate through the collection with a foreach. And call the Remove-MailboxPermission cmdlet with the needed attributes.

https://learn.microsoft.com/en-us/powershell/module/exchange/remove-mailboxpermission?view=exchange-ps

Something like this (sidenote: I can’t test it from phone but I will check it tomorrow from pc):

$user = [email protected]
$permissions = Get-MailboxPermission -Identity $user
foreach($permission in $permissions) {
  Remove-MailboxPermission -Identity $user -User $permission.User -AccessRights $permission.ExtendedRights -InheritanceType All
}

Edit: Or you can check this site and try the scripts on it. https://morgantechspace.com/2019/11/remove-mailbox-permissions-using-powershell.html