Margarita
asked on
Remove Mailbox Permissions
Dear all,
I need some help removing the mailbox permissions from a list of users:
When we terminate users we need to remove them from all the E-mails they have permissions to.
I usually run this command to see where the user has got permissions
Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User "Name User"
and then go to O365 and remove the delegation but I will have a mass termination procedure for many users and I need to automate this. It takes roughly 5 minutes to go through the whole tenant and check per user and then I need to go to O365 and remove it manually.
If anyone can give me guidance how to write this script is more than welcome.
Thank you.
I need some help removing the mailbox permissions from a list of users:
When we terminate users we need to remove them from all the E-mails they have permissions to.
I usually run this command to see where the user has got permissions
Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User "Name User"
and then go to O365 and remove the delegation but I will have a mass termination procedure for many users and I need to automate this. It takes roughly 5 minutes to go through the whole tenant and check per user and then I need to go to O365 and remove it manually.
If anyone can give me guidance how to write this script is more than welcome.
Thank you.
ASKER
This looks neat.
I will test it and I will let you know.
Thank you.
I will test it and I will let you know.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank u
I Assume you have the list of users in an array, as you say it takes about 5 min. and also i assume you can use Remove-MailboxPermission
Could you use Powershell ISE, and setup a foreach loop on the user list. Then for every user, get the list of Permissions, and store it in an array also, and do a foreach loop on every Identity in the list, to Remove-MailboxPermission each identity from the user.
pseudocode:
$Users = "list of users"
Foreach $User in $Users
(
Foreach $Ident in $id
(
Note: Not testet code, and only pseudo, so adapt for your needs.