Exchange 2010: Balancing the number of mailboxes and average size across all databases

You might have eight mailbox databases with plenty users created on them randomly, after running some time all mailboxes are now different in size and distributed uneven on all the databases. So has Microsoft any built tool to solve this problem, afraid not but the first step might be Mailbox Database Provisioning witch you can read about “here“.

So what’s the impact not have user on all databases even distributed? Well if you have 400 users that accessing one database instead of 50 users, the database with 50 users will more likely be more responsive and user will eventually have better experience than on the database that is accessed by 400 users if everything else is configured same way. Not always 100% true, it also depend what kind of user activity and how big mailboxes are and so on but you understand the concept.

It could look horrible as this:

(Those stats are gathered with fantastic script from Steve Goodmans’s Exchange blog, please get it “here“) 

Here you see for example that we have 65 mailboxes in Database-02 and 471 in Database-6, the average size for a mailbox in Database-02 is 2198MB and in Database-6 346MB, don’t look good ehhh?

So question is how do we solve this?

I haven’t found any cool ems script that both take count for average mailbox size and account of mailboxes in the database so there is some manual steps I’m afraid.

First we need to collect the users stats from all the databases on the server, we are especially interested in mailbox id, size and what database user resides on.

Get-Mailbox –Server “lab3-sv-exm-01” -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | select DisplayName, MailboxGuid, {$_.TotalItemSize.Value.ToMB()}, Database | Export-csv -Force -NoType C:\temp\mailboxes.txt

This exports all needed stats to C:\temp\mailboxes.txt 

Now download this Excel file “here

Looks like this

Now open the excel sheet and choose tab “Import-Sheet”

Click “Data” tab and choose “From Text” and point to C:\temp\mailboxes.txt export file.

Choose, Delimited and click Next


Select Tab and Comma and click Next

Click OK to finish the import

After import it looks something like this.

Now select all users from and click CTRL-C to copy

Change tab to the “input” tab in the Excel sheet, and paste in the copied users.

Now in the “new db” column, you see that I have an order 1-7 that is repeating itself, which are how many databases I have on my Exchange server. Here you need to modify to your to own configuration in your environment. If you for example have five databases it needs to be repeated 1-5 down to the last user.

As you can see my databases are called Database-01, Database-02 and so on, so now I need to format this to only numbers and remove everything else. I do this easy with “CTRL-F” in Excel and chose the “Replace” tab. I enter “Database-0” to remove this part and replace it with no value, click “Replace All” to do this for the whole sheet.

After the replace it will look something like this.

Now change to “SUM” tab in Excel sheet and preview the results after the move.

Looks better but not perfect, now you can go back to input tab and edit the destination database manually for some of the users to even further balance the move.

Last thing is to modify the ems script that’s generated for you in the “input” tab. Change to “input” tab and edit the generated ems line, change “Databse-0” to your own naming convention of yours database.

I know it’s not the ultimate way of balance the user on databases as it include a lot of steps but if anyone have an easier way please drop me an email.

This was tested on Exchange SP2

This entry was posted in Exchange 2010 and tagged , , , , , , , , , . Bookmark the permalink.

3 Responses to Exchange 2010: Balancing the number of mailboxes and average size across all databases

  1. NotSoCleverName says:

    I know that this is a year or more later, but if you serpentine your servers, you will get a better balance against your databases. All 4 of my databases were within a few MB of each other by doing it this way.

    Thanks for a great method. Hopefully Microsoft works this into a future release.

    • Hi!

      What do you mean by “serpentine your servers”?

      • Greg says:

        What he means is instead of going through the databases 1,2,3,4,5,6,7,1,2,3,4,5,6,7 Instead use 1,2,3,4,5,6,7,7,6,5,4,3,2,1. This will ensure a more even mailbox size distribution between the databases.

        My database stats: I have 3 databases and going through them in order I get a 74493MB, 69547MB, 66059MB. That is nearly 8.5GB difference between the first and the third database. If I serpentine them, I end up with MB, 69786MB, 69987MB and 70326MB. This brings the difference in size of my databases to just over half a GB.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s