PowerShell: Exports all shared mailboxes with permissions in Microsoft 365

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-MailboxPermission and 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.com with your admin email.
2025-02-03T16:16:41+01:00