PowerShell Genie

Mailbox size report

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Use Get-EXOMailboxStatistics to report mailbox item counts and total sizes, then sort the results to inspect the largest mailboxes first.

The script

1PS> Get-EXOMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Select-Object DisplayName,ItemCount,TotalItemSize | Sort-Object TotalItemSize -Descending

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 DisplayName ItemCount TotalItemSize
    2 ----------- --------- -------------
    3 Sample object 42 1.25 GB (1,342,177,280 bytes)
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-EXOMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Select-Object DisplayName,ItemCount,TotalItemSize | Sort-Object TotalItemSize -Descending
    1. Stage 1Get-EXOMailboxStatistics-ResultSize
    2. Stage 2Select-ObjectPositional values or no named parameters
    3. Stage 3Sort-Object-Descending

      How it works

      Get-EXOMailboxStatistics returns per-mailbox usage figures, the projection keeps the display name with ItemCount and TotalItemSize, and Sort-Object orders by size descending so the heaviest mailboxes surface first.

      Adapting it

      Feed it explicitly from a mailbox list, since these statistics cmdlets expect an identity: pipe Get-EXOMailbox -ResultSize Unlimited into Get-EXOMailboxStatistics so every mailbox is requested by name.

      Requirements

      ExchangeOnlineManagement module with a Connect-ExchangeOnline session.

      If the result is unexpected

      Mailbox size sorting looks wrong or returns blank values.

      Size values may be formatted objects or strings rather than numeric bytes, and some statistics may be unavailable.

      1. Inspect the returned size type for one mailbox and convert to a consistent numeric unit before sorting.

      Validate the result

      Sorted values follow numeric size order and missing statistics are marked unknown.

      Keep the check reliable

      Preserve bytes for calculation and create readable size labels only for presentation.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideMailbox size report

      Use Get-EXOMailboxStatistics to report mailbox item counts and total sizes, then sort the results to inspect the largest mailboxes first.