MicrosoftMicrosoft Office 365Powershell

How do I export a list of all mailboxes with their sizes in Exchange Online using PowerShell?

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

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

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.)

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button