You want to synchronize your on-premises users, for example with Office 365. Before you do…
Export Office 365 mailbox permissions to CSV
We want to get a list of Office 365 mailbox permissions because we like to know which user has access to which mailbox. The mailbox permissions are full access, send as, and send on behalf. Signing in to the Microsoft 365 admin portal and going through the users one by one to find the mailbox permissions takes a lot of time. An excellent way to export an Office 365 mailbox permissions report is with PowerShell. In this article, we will look at how to export Office 365 mailbox permissions to CSV with PowerShell.
Table of contents
Introduction
The script will go through all the users and shared mailboxes in Microsoft 365/Office 365 and export the mailbox permissions:
- Full Access
- Send As
- Send on Behalf
Note: Do you want to export Exchange on-premises mailbox permissions? Read the article Export mailbox permissions to CSV file.
Connect to Exchange Online
Before we can proceed further and export Office 365 mailbox permissions to CSV, we need to install and connect to Exchange Online PowerShell.
Start Windows PowerShell as administrator and run the cmdlet Connect-ExchangeOnline.
PS C:\> Connect-ExchangeOnline
Now that we are connected, we can go to the next step.
Prepare Get-MailboxPermissions PowerShell script
Create two folders on the C:\ drive:
- Temp
- Scripts
Download the Get-MailboxPermissions.ps1 PowerShell script and place it in C:\scripts folder. The script will export the CSV file to the C:\temp folder.
Run Get-MailboxPermissions PowerShell script
Get Office 365 mailbox permissions with PowerShell. First, change the path to the scripts folder. After that, run the script Get-MailboxPermissions.ps1.
PS C:\> cd c:\scripts\
PS C:\scripts> .\Get-MailboxPermissions.ps1
Open Office 365 mailbox permissions report CSV file
The Get-MailboxPermissions.ps1 PowerShell script will export Office 365 mailbox permissions to CSV file. Find the file MailboxPermissions.csv in the path C:\temp.
Open the CSV file with your favorite application. In our example, it’s Microsoft Excel.
The Office 365 mailbox permissions report looks excellent.
Out-GridView
Suppose you want to see the report in the grid view window. For example, you like to know how the report looks before you export it to CSV. If so, we can use the Out-GridView cmdlet.
Change line 59 from:
$Report | Sort -Property @{Expression = { $_.MailboxType }; Ascending = $False }, Mailbox | Export-CSV c:\temp\MailboxPermissions.csv -NoTypeInformation -Encoding UTF8
to:
$Report | Sort -Property @{Expression = { $_.MailboxType }; Ascending = $False }, Mailbox | Out-GridView
After changing the above line, let’s run the script to check its appearance in the grid view window.
The Office 365 mailbox permissions in the out grid view window look great.
Did this help you to export Office 365 mailbox permissions to CSV file?
Read more: Set default calendar permissions for all users with PowerShell »
Conclusion
You learned how to export Office 365 mailbox permissions with PowerShell. Get the Office 365 mailbox permissions report with Get-MailboxPermissions PowerShell script and have a close look through it. After reviewing, adjust the mailbox permissions to your needs.
Did you enjoy this article? You may also like Manage calendar permissions in Office 365 with PowerShell. Don’t forget to follow us and share this article.
Thank you for this amazing script. It helped me with over 500 mailboxes.
Thank for this amazing script… was facing the challenge of sorting out 300+ mailboxes and their respective trustee access… this made short work of it.
Is there a way to export for just one user? We have over 500 users and this will take forever!
Thank you very much for this script! This script gives a complete overview about all given rights in Exchange.
Thanks for the script.
We have several domains in our tenant. is it possible to read only a specific domain for the permissions?
for example exportScript.ps1 -domainName company123.com
best regards
Hi,
have already solved it as follows,
in the script in the second line
-Filter {EmailAddresses -like “*Domain.com*”}
I only get the following error, even without my adjustment of the filter
Get-ExoRecipient : Error while querying REST service. HttpStatusCode=500 ErrorMessage=Microsoft.OData.ODataException: Bad Request – Error in query
syntax.
at Microsoft.OData.UriParser.ODataPathParser.ExtractSegmentIdentifierAndParenthesisExpression(String segmentText, String& identifier, String&
parenthesisExpression)
I got the CSV exported despite this, but the error always occurs.
But the scripts works.
Jannis
thank for share, but how if in exchange on premises? please advice
You can follow the article: Export mailbox permissions to CSV file.