Monthly Archives: November 2009

Script for Mailbox Count per Storage Group

Applies to: Exchange Server 2007

The following Exchange Management Shell script displays the mailbox count per storage group.

Step 1: Create a new text file in C:Scripts named “Get-MailboxCountPerStorageGroup.ps1” and paste the code below into the text file.

$totalcount = 0
Get-StorageGroup | sort -property name | Get-MailboxDataBase | foreach {
$storagegroup = $_.storagegroup
$database = $
get-mailbox -database $database | foreach {$t=0} {$t +=1} {
“$t Mailboxes in $storagegroup”
$totalcount = $totalcount + $t
“Total Count: $totalcount”

Step 2: Once you have saved the text file, run the script file by entering it’s name into the Exchange Management Shell, (C:ScriptsGet-MailboxCountPerStorageGroup.ps1).

The output will look similar to this:

45 Mailboxes in mbserverFirst Storage Group
23 Mailboxes in mbserverSecond Storage Group
Total Count: 68