How do I export a list of all mailboxes with their sizes in Exchange Online using PowerShell?
Table of Contents
As an Exchange Online administrator, keeping tabs on mailbox sizes is crucial for storage management and preventing users from hitting their quotas. Need to check Exchange Online mailbox sizes with PowerShell? PowerShell provides a powerful way to gather this information and export it into a usable format like a CSV file, ideal for creating an Exchange Online mailbox size report. Let’s dive in!
Prerequisites
- Exchange Online PowerShell:Â You’ll need access to the Exchange Online PowerShell module, often accessible through the Exchange Management Shell.
- Administrative Permissions:Â Ensure you have the appropriate permissions to manage mailboxes in your Exchange Online organization.
Steps
1: Connect to Exchange Online PowerShell Open PowerShell and use the following command:
Connect-ExchangeOnline
Provide your Exchange Online administrator credentials when asked.
2: Gather Mailbox Size Data
We’ll use the Get-MailboxStatistics
cmdlet to retrieve size information:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName,TotalItemSize
Get-Mailbox -ResultSize Unlimited
: Fetches all mailboxes in your organization.Get-MailboxStatistics
: Gets mailbox usage details.Select-Object DisplayName,TotalItemSize
: Focuses on the mailbox name and size.
3: Export to CSV
Pipe the output to the Export-Csv
cmdlet to create a well-formatted file:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName,TotalItemSize | Export-Csv -Path mailbox_sizes.csv -NoTypeInformation
-Path mailbox_sizes.csv
: Specifies the name and location of your output file.-NoTypeInformation
: Keeps the CSV file clean and easy to work with.
Advanced Tips
Sorting: Sort your results by size to quickly pinpoint the largest mailboxes:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, TotalItemSize | Export-Csv -Path mailbox_sizes.csv -NoTypeInformation
Filtering: Focus on specific mailbox types:
Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Get-MailboxStatistics | ...
``` (Replace 'UserMailbox' with 'SharedMailbox', 'RoomMailbox', etc.)
Now you have a detailed list of mailboxes and their sizes, making storage management in Exchange Online a breeze!
Let me know if you’d like to explore additional filtering or reporting options with PowerShell!