'Exchange online - Copy mailbox permissions from one user to another

I'm Trying to find a way to copy a users mailbox permissions to another user, I can output the data I need in PS just can't find a way to then apply those permissions to the new user.

I'm not amazing with PS so please bare with me :)

Get-Mailbox -RecipientTypeDetails UserMailBox,SharedMailbox | Get-MailboxPermission -User

which then outputs the users permissions but I would like to be able to then add those permissions to my new user in the same script.



Solution 1:[1]

hope this helps:

$FromUser = Read-Host "Enter the email address of the user you want to copy mailbox permissions from"
$ToUser = Read-Host "Enter the email address of the user you want to set mailbox permissions for"

$Perm = Get-Mailbox | Get-MailboxPermission -User $FromUser

$Perm | ForEach-Object { $_ 
Add-MailboxPermission -Identity $_.Identity -AccessRights FullAccess -InheritanceType All -AutoMapping:$true -User $ToUser
Add-RecipientPermission -Identity $_.Identity -AccessRights SendAs -Confirm:$false -Trustee $oTUser
}

This will automatically find the permissions from User1 to User2. You can change the Parameters to whatever you want to put based on Microsofts allowed commands.

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

https://docs.microsoft.com/en-us/powershell/module/exchange/add-recipientpermission?view=exchange-ps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 daaqis