Getting the number of mailboxes per database in your Exchange Organization

How to create a single line PowerShell to retrieve the number of mailboxes per mailbox database in your organization. I was asked about that number in one of my customers and that was the reason behind of this Tutorial.


First, we need to identify the mailbox databases that we are looking to retrieve the number of mailboxes. In the current environment I have a considerable amount of databases spread all over my organization. That is simple, just using the cmdlet Get-MailboxDatabase.


The Exchange Management Console way…

If you are running Exchange Server 2010, you can use the traditional way which is creating a filter based on the mailbox database and that will generate a list of all mailboxes, and we can check the total number of mailboxes on the upper right side of the window.



The PowerShell way…

The solution is simple, just run the following command line and it will generate a list of all mailbox databases and the number of mailboxes hosted on each one of them.

Get-MailboxDatabase | foreach  { sleep 5; write-host; Write-Host (“The Mailbox Database ” + $_.Name + ” currently has ” + (get-mailbox -Database $_.Name).count + ” mailboxes hosted on it.”) }