Hossain Labs

Home / Blog / Exchange Online

Unveiling Primary Mailbox Statistics

By Md Sajid Hossain3 June 2025Updated 1 December 20261 min read

A mailbox storage report should tell you which mailboxes are largest and how many items they contain. Check primary and archive usage separately before combining the results.

Check one primary mailbox

Connect to Exchange Online PowerShell and substitute the mailbox address. ItemCount and TotalItemSize describe the store you queried.

PowerShell
Get-EXOMailboxStatistics -Identity user@contoso.com |
    Select-Object DisplayName, ItemCount, TotalItemSize

Check the archive

For an active archive, add the switch to the statistics command itself. Selecting users who have an archive is only the first step.

PowerShell
Get-EXOMailboxStatistics -Identity user@contoso.com -Archive |
    Select-Object DisplayName, ItemCount, TotalItemSize

Export the report

This example writes one row per store in the current directory. The address and Store columns let you compare a user’s two rows. TotalItemSize is exported as displayed text. Sorting that text alphabetically will not rank mailboxes by size.

PowerShell
$mailboxes = Get-EXOMailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited -Properties ArchiveStatus
$rows = foreach ($mailbox in $mailboxes) {
    $address = $mailbox.PrimarySmtpAddress.ToString()
    $stores = @('Primary')
    if ($mailbox.ArchiveStatus -eq 'Active') { $stores += 'Archive' }
    foreach ($store in $stores) {
        $params = @{ Identity = $address; ErrorAction = 'Stop' }
        if ($store -eq 'Archive') { $params.Archive = $true }
        try {
            $stats = Get-EXOMailboxStatistics @params
            [pscustomobject]@{ Address = $address; Store = $store; Items = $stats.ItemCount; Size = $stats.TotalItemSize }
        } catch {
            Write-Warning "Could not read $store for $address. $($_.Exception.Message)"
        }
    }
}
$rows | Export-Csv -Path ./MailboxStorage.csv -NoTypeInformation

Check the warnings and compare one user’s CSV rows with the individual queries above. A missing row does not mean the mailbox contains no data.

References

Md Sajid Hossain

Modern Workplace & Data Security Engineer in Dhaka. Microsoft 365, Purview, Entra ID and Exchange, from real tenants and support cases.

Work with me · LinkedIn