PowerShell script: Get-UsersPerDB

I’m working on an Exchange migration project. I did a green field Exchange 2013 deployment to migrate users to from a hosted solution. During the process I created about 3200 new mailboxes, and I must have done something wrong because those mailboxes ended up all clumped up in a couple of the databases. The problem I ran into is there is no good way to see your mailbox distribution across a number of databases in the Exchange Admin Console.

I did some quick internet searches and didn’t come up with an existing script that gave me the information I wanted. There might be one out there, but I figured I’d get a blog post out of it if I wrote my own.

The information I was looking for was a simple list of the databases in my Exchange environment with the number of mailboxes in each database, and the total size of each database. After a bit of tinkering around I came up with Get-UsersPerDB.

Running this script give you an output that looks like this

A simple list of database, number of mailboxes, and total size of the database. For good measure, I added a line that tells you the total number of mailboxes in your environment in case you’re really bad at addition.

My next task was to straighten out the mailboxes so they were more evenly distributed across the databases, but Steve Goodman already has a great script for that so there was no need for me to duplicate that effort.