Export Mailbox Statistics

Get mailbox statistics and export them to a CSV file. Use the Connect-ExchangeOnline function to use this code.

Get-Mailbox -RecipientTypeDetails UserMailbox | ForEach-Object {
Get-MailboxStatistics $_.PrimarySmtpAddress
} | Select DisplayName, ItemCount, TotalItemSize | Export-Csv -Path "MailboxStatistics.csv" -NoTypeInformation
rCredential