Skip to main content

Statistic helpers

For full details and examples, run Get-Help Export-MboxStatistics -Detailed or Get-Help Get-MboxStatistics -Detailed. CSV export commands in this section finish with a success message that includes the generated CSV path, and they do not echo the path as a second pipeline line.

Export-MboxStatistics

Export mailbox statistics (size, quotas, archive info) either to CSV (all mailboxes) or as objects (single mailbox). The CSV export can flush in batches, resume from the latest matching CSV, or resume from a specific file.

Syntax

Export-MboxStatistics [-UserPrincipalName <String>] [-CsvFolder <String>] [-CsvPath <String>] [-Round] [-BatchSize <Int>] [-Resume] [-MaxConsecutiveErrors <Int>]
ParameterTypeDescriptionRequiredDefault
UserPrincipalNameStringOptional single mailbox identity; when omitted, all mailboxes are exported to CSV.No-
CsvFolderStringOutput folder (for all-mailbox export).NoCurrent directory
CsvPathStringOptional CSV file to resume. When omitted with -Resume, the most recent matching CSV in CsvFolder is used.No-
RoundSwitchRound quota values up to the nearest integer GB.NoFalse
BatchSizeIntFlush to CSV every N mailboxes.No25
ResumeSwitchResume from an existing mailbox statistics CSV instead of starting a new report.NoFalse
MaxConsecutiveErrorsIntStop after this many mailbox-level failures in a row.No5

Examples

# Export every mailbox to CSV (batched writes)
Export-MboxStatistics -CsvFolder 'C:\Temp\Reports' -Round

# Resume from the latest matching CSV in the folder
Export-MboxStatistics -CsvFolder 'C:\Temp\Reports' -Resume

# Resume from a specific CSV file
Export-MboxStatistics -CsvPath 'C:\Temp\Reports\20260414_M365-MailboxStatistics.csv' -Resume

# Inspect a single mailbox as objects
Export-MboxStatistics -UserPrincipalName 'user@contoso.com'

Export-MboxDeletedItemSize

Export deleted item store usage for user mailboxes. The report is exported to CSV by default and can be flushed in batches or resumed from a previous CSV. The CSV includes UserPrincipalName so resume can skip already exported mailboxes safely.

Syntax

Export-MboxDeletedItemSize [[-UserPrincipalName] <String[]>] [-CsvFolder <String>] [-Csv] [-BatchSize <Int32>] [-Resume] [-CsvPath <String>] [-MaxConsecutiveErrors <Int32>]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, Identity, Mailbox, SourceMailbox)String[]Optional mailbox identity or identities. When omitted, all user mailboxes are scanned. Pipeline accepted.No-
CsvFolderStringDestination folder for the CSV file.NoCurrent directory
CsvBooleanExport the report to CSV. Use -Csv:$false to return objects instead.NoTrue
BatchSizeIntFlush partial results every N processed mailboxes.No25
ResumeSwitchResume from the latest matching CSV in CsvFolder or from CsvPath.NoFalse
CsvPathStringExplicit CSV file to resume.No-
MaxConsecutiveErrorsIntStop after this many consecutive mailbox-level failures.No5

Examples

# Export all user mailboxes to CSV
Export-MboxDeletedItemSize
# Export a subset of mailboxes to a custom folder
'user1@contoso.com','user2@contoso.com' | Export-MboxDeletedItemSize -CsvFolder 'C:\Temp\Reports'
# Resume from the latest matching CSV in the folder
Export-MboxDeletedItemSize -CsvFolder 'C:\Temp\Reports' -Resume

Get-MboxStatistics

Return a simplified mailbox statistics view as objects.

Syntax

Get-MboxStatistics [-UserPrincipalName <String>] [-IncludeArchive] [-IncludeMessageActivity] [-Round]
ParameterTypeDescriptionRequiredDefault
UserPrincipalNameStringOptional mailbox identity (also from pipeline, including multiple values); when omitted, all mailboxes are returned.No-
IncludeArchiveSwitchInclude archive size, quota, and usage info when archive is enabled.NoFalse
IncludeMessageActivitySwitchInclude message activity fields (LastReceived, LastSent, OldestItemReceivedDate, OldestItemFolderPath).NoFalse
RoundSwitchRound quota values up to the nearest integer GB.NoTrue

Output (main fields)

  • DisplayName
  • UserPrincipalName
  • PrimarySmtpAddress
  • MailboxTypeDetail
  • ArchiveEnabled
  • MailboxSizeGB
  • ItemCount
  • MailboxCreated
  • LastLogonTime
  • WarningQuotaGB
  • ProhibitSendQuotaGB
  • PercentUsed
  • LastReceived (only with -IncludeMessageActivity)
  • LastSent (only with -IncludeMessageActivity)
  • OldestItemReceivedDate (only with -IncludeMessageActivity)
  • OldestItemFolderPath (only with -IncludeMessageActivity)
  • ArchiveSizeGB (only with -IncludeArchive)
  • ArchiveQuotaGB (only with -IncludeArchive)
  • ArchivePercentUsed (only with -IncludeArchive)

Examples

# Quick glance at a single mailbox
Get-MboxStatistics -UserPrincipalName 'user@contoso.com'

# Include archive data
Get-MboxStatistics -UserPrincipalName 'user@contoso.com' -IncludeArchive

# Include message activity (latest trace + oldest item details)
Get-MboxStatistics -UserPrincipalName 'user@contoso.com' -IncludeMessageActivity

# Multiple mailboxes from pipeline
'user1@contoso.com','user2@contoso.com','user3@contoso.com' | Get-MboxStatistics -IncludeArchive

# All mailboxes (may take a while due to message trace queries)
Get-MboxStatistics -IncludeMessageActivity