Exchange 2007 : Generating Mailbox Statistics Report

Exchange 2007 : Generating Mailbox Statistics Report

Use the following ommand from the Exchange shell to generate the report on a per-mailbox database basis:

get-mailboxstatistics -Database “[database name]” | select-object servername, storageGroupname, databasename, DisplayName, @{name=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount | export-csv c:\DB_Stats.csv

You can also format the data on screen using the following command:

get-mailboxstatistics -Database “[database name]” | ft servername, storageGroupname, databasename, DisplayName, @{label=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount

You can also report on an entire server using the command:

get-mailboxstatistics -Server “[server name]” | select-object servername, storageGroupname, databasename, DisplayName, @{name=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount | export-csv c:\Server_Stats.csv

Format-table is designed to display data in a readable format on screen, select-object is designed for exporting data:

  • When using ft you should use @{label=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB()}}
  • When using select-object use @{name=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB()}}

If you try to use @{label=”TotalItemSize(KB)”;expression={$_.TotalItemSize.Value.ToKB when using export-csv you will end up with an invalid csv file that contains multiple lines of: 27c87ef9bbda4f709f6b4002fa4af63c