As I was running a mailstorm against my Exchange 2007 virtual environment, I noticed that for some reason I had a few mailboxes that were missed in the random seeding that was happening. I didn’t really care that these were missed, since I already had a system configuration of around 1500 mailboxes. I mean really, who needs more for a test environment.
Anyway, I wanted to get rid of these non-populated mailboxes, but with 1500 mailboxes, I did not want to go through each and every mailbox within Exchange Management Console and hit properties to see if there was data contained in the selected mailbox. Under Exchange 2003, Microsoft gave us a great pair of columns (Size and Total Items). In Exchange 2007, Microsoft removed this and I have not seen nor heard any movement to bring it back.
In any case, I needed a way to get a list of the mailboxes showing me this information. Fortunately, Exchange Management Shell provide a way to do this via the Powershell cmdlet Get-MailboxStatistics. Here is what I ended up using to generate this and send to the screen. I played a little with Export-CSV, but was not able to get the proper data in the file, so I left the sort with smallest mailboxes at the bottom.
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=”TotalItemSize(MB)”;expression={$_.TotalItemSize.Value.ToMB()}},ItemCount
This will output a list of all of mailboxes sorted by Item Size and Item Count (highest to lowest). This makes it easy enough for me to get a list of my non-populated mailboxes to remove them from the system. I have also used this to remove my larger mailboxes to free up some disk space in my test environment.