- Migrate to REST Cmdlets: Legacy remote PowerShell (
Get-Mailbox/Get-MailboxStatistics) is retired; useGet-EXOMailboxandGet-EXOMailboxStatisticsinExchangeOnlineManagementv3+ for faster, auto-throttled REST execution. - Complete Storage Visibility: A production report should capture Primary Mailbox Size (GB), Deleted Items Size, ProhibitSendReceiveQuota, and In-Place Archive Size in a single pass.
- Automation Ready: Run unattended via Certificate-Based App-Only authentication (
-AppId+-CertificateThumbprint) and export directly to CSV.
Monitoring mailbox storage growth in Microsoft 365 / Exchange Online prevents unexpected ProhibitSend quota lockouts for executives, shared mailboxes, and automated service accounts.
Legacy scripts built on New-PSSession and Get-MailboxStatistics frequently fail with WinRM timeouts or Basic Auth blocks. In this updated 2026 Runbook, we use the modern REST-based ExchangeOnlineManagement v3 cmdlets (Get-EXOMailbox and Get-EXOMailboxStatistics) to generate a fast, accurate CSV report covering both Primary and Archive mailboxes.
Architecture: How REST Mailbox Size Reporting Works
PowerShell Script: Exchange Online Mailbox Size & Archive Report
Run the following script using PowerShell 7 and the ExchangeOnlineManagement v3+ module. It connects unattended via Certificate-Based App-Only Auth (or interactively via Connect-ExchangeOnline), queries primary and archive statistics, and exports a clean CSV:
# Connect to Exchange Online (Certificate-Based App-Only Auth)
Connect-ExchangeOnline `
-AppId "c841ae33-4093-4385-8a90-6a530761f9b9" `
-Organization "xzf58.onmicrosoft.com" `
-CertificateThumbprint "BEAC429DE404B46FF030811C0C9DE00DE701C027" `
-ShowBanner:$false
$Mailboxes = Get-EXOMailbox -ResultSize Unlimited -Properties ProhibitSendReceiveQuota, ArchiveStatus
$Report = foreach ($Mbx in $Mailboxes) {
$Stats = Get-EXOMailboxStatistics -Identity $Mbx.UserPrincipalName `
-Properties LastLogonTime, TotalItemSize, ItemCount, TotalDeletedItemSize -ErrorAction SilentlyContinue
# Parse byte count cleanly from ByteQuantifiedSize string
$SizeMB = if ($Stats.TotalItemSize -match "\(([\d,]+) bytes\)") {
[math]::Round(([double]($Matches[1] -replace ",", "")) / 1MB, 2)
} else { 0 }
$ArchiveMB = $null
if ($Mbx.ArchiveStatus -eq "Active") {
$ArchStats = Get-EXOMailboxStatistics -Identity $Mbx.UserPrincipalName -Archive -ErrorAction SilentlyContinue
if ($ArchStats.TotalItemSize -match "\(([\d,]+) bytes\)") {
$ArchiveMB = [math]::Round(([double]($Matches[1] -replace ",", "")) / 1MB, 2)
}
}
[PSCustomObject]@{
DisplayName = $Mbx.DisplayName
PrimarySmtpAddress = $Mbx.PrimarySmtpAddress
RecipientTypeDetails = $Mbx.RecipientTypeDetails
ItemCount = $Stats.ItemCount
PrimarySizeMB = $SizeMB
ArchiveStatus = $Mbx.ArchiveStatus
ArchiveSizeMB = $ArchiveMB
Quota = $Mbx.ProhibitSendReceiveQuota
LastLogonTime = $Stats.LastLogonTime
}
}
$Report | Sort-Object PrimarySizeMB -Descending | Format-Table -AutoSize
$Report | Sort-Object PrimarySizeMB -Descending | Export-Csv -Path ".\EXO_Mailbox_Size_Report.csv" -NoTypeInformation -Encoding UTF8
Disconnect-ExchangeOnline -Confirm:$false
Live Output from Our LAB 365 (xzf58.onmicrosoft.com) Tenant:
DisplayName PrimarySmtp ItemCount TotalItemSize LastLogonTime
----------- ----------- --------- ------------- -------------
Sunil Chauhan [email protected] 1280 199.7 MB (209,449,565 bytes) 11/25/2026 3:47:20 AM
shri [email protected] 1093 190.7 MB (199,989,061 bytes) 10/30/2025 3:14:39 AM
Patti Fernandez [email protected] 30 2.096 MB (2,198,130 bytes)
Miriam Graham [email protected] 23 1.086 MB (1,138,900 bytes)
Diego Siciliani [email protected] 16 598.6 KB (613,011 bytes)
💬 Reader Comments & Feedback
Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.
Leave a Comment or Report an Update