2012-11-14

Some PowerShell scripts to query Exchange server


Some PowerShell scripts to query Exchange server.

They need to executed them in the Exchange Management Console .
·         check the current message tracking settings
get-transportserver your-server-name | fl *Message*

Note, by default Exchange 2007/2010 has the message tracking enabled and the server keeps log files for recent 30 days only.

·         List all mailboxes and size:
Get-MailboxDatabase "your Mailbox Database name" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount

·         Show sum of mailboxes:
Get-Mailbox -Database "your Mailbox Database name" | Get-MailboxStatistics | %{$_.TotalItemSize.Value.ToMB()} | Measure-Object -sum  -average -max -min


·         Show received mails statistics during a given period:
Get-MessageTrackingLog -Server your-server-name -EventID receive -Start 13/10/2012 -End 11/11/2012 -resultsize unlimited |Select-Object TotalBytes | Measure-Object -Property TotalBytes -maximum -minimum -average –sum

·         Show received mails statistics during a given period:
Get-MessageTrackingLog -Server your-server-name -EventID send -Start 13/10/2012 -End 11/11/2012 -resultsize unlimited |Select-Object TotalBytes | Measure-Object -Property TotalBytes -maximum -minimum -average -sum

References: