This script that will connect to Microsoft 365, retrieve all shared mailboxes, and list the users who have permissions on each mailbox. The results will be exported to a CSV file.
Copy to Clipboard
Explanation:
- It retrieves all shared mailboxes using
Get-Mailbox -RecipientTypeDetails SharedMailbox. - It fetches permissions using
Get-MailboxPermissionand filters out system accounts. - The output is stored in
C:\SharedMailboxPermissions.csv.
Permissions Explanation:
FullAccess– User can open and manage mailbox items.SendAs– User can send emails as the shared mailbox.SendOnBehalf– User can send emails on behalf of the shared mailbox.
Prerequisites:
- You must be a Microsoft 365 admin or have Exchange admin privileges.
- Replace
admin@yourdomain.comwith your admin email.