Introduction
In modern Microsoft 365 environments, managing shared mailboxes efficiently is crucial. Whether it’s assigning permissions, identifying mailbox managers, or exporting detailed reports, PowerShell makes these tasks seamless. This blog will walk you through PowerShell scripts that help you manage shared mailbox permissions, set managers, and export data—all explained in a simple, human-readable way for both technical and non-technical users.
Viewing Permissions for a Specific User on All Shared Mailboxes
PowerShell Script:
Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Get-MailboxPermission | Select-Object * | Where-Object {($_.user -like 'UserEmailAddress')}
Explanation:
– This command retrieves all shared mailboxes in your organization.
– Then it pipes the output to ‘Get-MailboxPermission’ which lists all the permissions on each mailbox.
– ‘Select-Object *’ grabs all available fields.
– ‘Where-Object’ filters results to only those where the ‘user’ matches the specified email address.
Sample Output:
Identity User AccessRights IsInherited
——– —- ————- ———–
FinanceShared@domain.com user@domain.com FullAccess False
Exporting Shared Mailbox Permissions to a CSV File
PowerShell Script:
Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Get-MailboxPermission | Select-Object Identity,User,AccessRights,IsOwner | Export-CSV "C:\Users\Desktop\Information.csv"
Explanation:
– This command is similar to the one above but only selects key fields like mailbox name, user, and their access rights.
– The results are exported directly to a CSV file so you can analyze it easily in Excel.
Expected Output in CSV:
Identity,User,AccessRights,IsOwner
FinanceShared@domain.com,user@domain.com,{FullAccess},False
Assigning a Manager to a Shared Mailbox
PowerShell Script:
Set-User -Identity 'SharedMailboxEmailAddress' -Manager "ManagerEmailAddress" -Confirm:$false
Explanation:
– This command assigns a manager to a shared mailbox.
– ‘-Confirm:$false’ skips the confirmation prompt for automation convenience.
Output:
There will be no console output, but the manager assignment will be updated in the user object.
Exporting Shared Mailbox Manager Information
PowerShell Script:
Get-Mailbox -Identity 'SharedMailboxName' | Select Name,@{n='Manager';e={(Get-User $_.name).manager}} | Export-CSV "C:\Users\Desktop\Information.csv" -NoTypeInformation
Explanation:
– Retrieves the shared mailbox by name.
– Selects the mailbox name and uses a calculated property to fetch its manager.
– Exports the data to a CSV file without type information.
Expected Output in CSV:
Name,Manager
FinanceShared,manager@domain.com
Final Thoughts
Using PowerShell, you can quickly manage shared mailbox permissions and assign managers with ease. These scripts are powerful tools for Microsoft 365 administrators looking to streamline operations. Make sure to replace placeholder emails with actual addresses from your organization. Stay tuned for more PowerShell tips and best practices!