How to List Microsoft 365 User Mailbox and Archive Storage Usage via PowerShell Print

  • PowerShell, Storage, Archive, Exchange
  • 0

Overview

This article explains how to use PowerShell to generate a report of all Microsoft 365 user mailbox sizes, including their auto-archive mailbox usage where applicable. This is useful for monitoring storage consumption across your tenant.

Prerequisites

  • Exchange Online PowerShell module installed
  • Microsoft 365 Global Administrator or Exchange Administrator access
  • An active connection to Exchange Online PowerShell

Step 1 - Connect to Exchange Online PowerShell

If you are not already connected, run the following command in an elevated PowerShell session:

Connect-ExchangeOnline

Sign in with your administrator credentials when prompted.

Step 2 - Run the Mailbox Storage Report

Run the following command to retrieve the primary and archive mailbox sizes for all users in the tenant:

Get-Mailbox -ResultSize Unlimited | ForEach-Object {
    $primary = Get-MailboxStatistics -Identity $_.UserPrincipalName
    $archive = Get-MailboxStatistics -Identity $_.UserPrincipalName -Archive -ErrorAction SilentlyContinue
    [PSCustomObject]@{
        User        = $_.UserPrincipalName
        PrimarySize = $primary.TotalItemSize
        ArchiveSize = if ($archive) { $archive.TotalItemSize } else { "No Archive" }
    }
} | Format-Table -AutoSize

Step 3 - Review the Output

The command will return a table with the following columns:

  • User - the user's email address (UserPrincipalName)
  • PrimarySize - the total size of the user's primary mailbox
  • ArchiveSize - the total size of the user's archive mailbox, or No Archive if no archive mailbox exists

Optional - Export Results to CSV

To save the results to a CSV file for reporting or documentation, replace Format-Table -AutoSize at the end of the command with the following:

Export-Csv -Path "C:\Temp\MailboxSizes.csv" -NoTypeInformation

The full command with export would look like this:

Get-Mailbox -ResultSize Unlimited | ForEach-Object {
    $primary = Get-MailboxStatistics -Identity $_.UserPrincipalName
    $archive = Get-MailboxStatistics -Identity $_.UserPrincipalName -Archive -ErrorAction SilentlyContinue
    [PSCustomObject]@{
        User        = $_.UserPrincipalName
        PrimarySize = $primary.TotalItemSize
        ArchiveSize = if ($archive) { $archive.TotalItemSize } else { "No Archive" }
    }
} | Export-Csv -Path "C:\Temp\MailboxSizes.csv" -NoTypeInformation

Notes

  • This command may take several minutes to complete on large tenants with many users
  • Users without an archive mailbox enabled will show No Archive in the ArchiveSize column
  • Mailbox sizes are displayed in bytes by default - the CSV export is useful for sorting and filtering in Excel
  • Always run PowerShell as Administrator and ensure you are connected to Exchange Online before running this command

Was this answer helpful?

« Back