export shared mailbox permission

Super Contributor



i have script below to export permission of shared mailbox.

issue is that the exported csv file exported 1 shared mailbox only.




Import-Module ExchangeOnlineManagement

Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $truE

$mailboxes=Get-Mailbox -ResultSize unlimited -RecipientTypeDetails SharedMailbox

foreach($mailbox in $mailboxes){

Get-MailboxPermission $mailbox.name | select Identity,User,AccessRights | Export-Csv C:\Users\contoso\Desktop\sharedmailbox.csv –NoTypeInformation







1 Reply

You are effectively overwriting the CSV file on each iteration, use the -Append switch:


Export-Csv C:\Users\contoso\Desktop\sharedmailbox.csv –NoTypeInformation -Append


I would also suggest to use a proper identifier for the mailbox, as Name might not be unique. Something like $mailbox.UserPrincipalName should work better.