Wednesday, October 20, 2010

Getting Database counts per Exchange Server via PowerShell

Was recently asked to generate a report of the total count of items per Exchange database per server. This one-liner (broken up for readability), takes care of it.
Get-MailboxServer | Get-MailboxStatistics | `
Sort-Object DatabaseName | `
Select DatabaseName, ItemCount | `
Group-Object -Property DatabaseName | `
Foreach {
$items = ($_.Group | Measure-Object -Property ItemCount -sum).Sum
"{0}`t{1:N0}" -f $_.Name,$items
}
This will generate something like the following:
Exchange01-DB011,372,127
Exchange01-DB021,522,356
Exchange01-DB031,406,486
Exchange01-DB041,345,962
Exchange01-DB051,330,690
Exchange01-DB061,392,853
Exchange01-DB071,318,130
..........


Enjoy!

1 comment:

Alex said...

To my way of thinking ms exchange is very interesting and difficult software. Several days ago I ran into the unpleasant issue and only thanks to one tool I could work out it. This program proved all its capabilties for working out almost every problems with ms exchange - restore contact list from microsoft exchange server.