Feb 16 2021 06:42 PM
hi,
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
}
Write-Host "DONE RUNNING SCRIPT"
__________________________________________________________________
Feb 16 2021 11:45 PM
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.