Skip to content

Count mailboxes per database in Exchange with PowerShell

Sometimes you want to get a count of mailbox/mailboxes per database in Exchange. But, why do you need to get this information? For example, you want to distribute the mailboxes in the databases. Let’s find out how to get Exchange 2010/2013/2016/2019 mailbox count with PowerShell.

Note: Do you want to get the size of each mailbox? Read the article Get mailbox size of all users in Exchange with PowerShell.

Mailbox count per database in Exchange with PowerShell

Find the total mailboxes in each database. We will use the Get-Mailbox cmdlet.

Run Exchange Management Shell as administrator.

[PS] C:\>Get-Mailbox -ResultSize Unlimited | Group-Object -Property:Database | Select-Object Name, Count | Sort-Object Name | Format-Table

Name Count
---- -----
DB01   235
DB02   249
DB03   292
DB04   437

Count the archive mailboxes in each database.

[PS] C:\>Get-Mailbox -ResultSize Unlimited | Where-Object {$_.ArchiveDatabase -notlike $null} | Group-Object -Property:Database | Select-Object Name, Count | Sort-Object Name | Format-Table

Name Count
---- -----
DB01     5
DB02    21

It’s a great command to know how many mailboxes are in each Exchange database.

Mailbox count of a specific database in Exchange

The previous command will count the mailboxes in all the databases. That’s great, but if you have a lot of databases, it will take time. That is when you can search and get the count for a specific database.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Database "DB01" | Group-Object -Property:Database | Select-Object Name, Count | Format-Table

Name Count
---- -----
DB01   235

Count the archive mailboxes in a specific database.

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Database "DB01" | Where-Object {$_.ArchiveDatabase -notlike $null} | Group-Object -Property:Database | Select-Object Name, Count | Sort-Object Name | Format-Table

Name Count
---- -----
DB01     5

It’s an excellent command if you want to know how many mailboxes are in a specific Exchange database.

Conclusion

You learned how to count mailboxes per database in Exchange with PowerShell. You can use the mailbox count commands in Exchange 2010/2013/2016/2019. The first command will list all the databases count in the organization. Run the second command if you only want to find the count of a specific database.

Did you enjoy this article? You may also like Count mailboxes per Exchange Server with PowerShell. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *