Exchange 2010 introduces new functionality in which you can automatically assign a database to a user during the provisioning process. If a database name is not provided to the database parameter of the New-Mailbox cmdlet, a database will be selected automatically. Provisioned mailboxes will be created in a "load balanced" manner across all of the available mailbox databases in the same Active Directory site as the provisioning server – spreading the load, so to speak.
Load balanced mailbox provisioning is made possible by the Mailbox Resources Management cmdlet extension agent. The Mailbox Resources Management Agent is enabled by default, and can be managed using the *-CmdletExtensionAgent cmdlets.
Load Balanced Mailbox Provisioning in Action
I wanted to see how evenly the mailboxes are distributed amongst the available databases when importing a batch of new users from a CSV file. In my lab, I have three mailbox databases; DB1, DB2 and DB3. I created a total of 20 new mailboxes from a CSV file using the following steps:
First, create a password for all the accounts:
$password = ConvertTo-SecureString -AsPlainText "P@ssw0rd01" -Force
Then, create a hashtable that will be used to track the total amount of mailboxes that are created in each database. Next, import the CSV file, create the mailboxes, and increment the database count where the mailbox is created:
$db = @{} Import-Csv C:\mailboxes.csv | %{ New-Mailbox -Name $_.name -Alias $_.alias -Password $password -UserPrincipalName $_.upn | %{ $db[$_.database] = $db[$_.database] + 1 } } write $db
After the mailboxes are created return the hashtable with the total number of mailboxes created in each database. Here's the output from running the above code:

As you can see in the above screen shot, I provisioned 20 mailboxes that were created evenly across each database – 6 mailboxes were created in DB1, and 7 mailboxes were created in both DB2 and DB3. So, from this example we can tell that this new feature does a very good job of distributing the load when provisioning multiple mailboxes.
Excluding Databases from the Provisioning Process
You can permanently exclude databases from provisioning by setting the IsExcludedFromProvisioning property value to $true on a particular database. For example, to exclude DB2, we would run the following EMS command:
Set-MailboxDatabase DB2 -IsExcludedFromProvisioning:$true

If you want to temporarily exclude the database from provisioning, set the IsSuspendedFromProvisioning property value to $true, for example:
Set-MailboxDatabase DB2 -IsSuspendedFromProvisioning:$true

So, with this in mind, I suspended DB2 from provisioning and used the code from my previous example to create another 20 mailboxes from a CSV import file to see how the new mailboxes are distributed on each available database:

We can see from the output shown above that DB2 was not used, and we've got pretty even distribution of mailboxes across both available databases.
This may seem like a small improvement over Exchange 2007, but it obviously works very well and has already proven to be very useful in my mailbox provisioning scripts.





{ 4 trackbacks }
{ 6 comments… read them below or add one }
Thank you for the post Mike. Would the same even distribution of mailboxes also apply using the New-MoveRequest cmdlet? We will be transitioning mailboxes off a 2003 system to 2010 and I’m looking for the best method to balance out the Exchange databases.
An additional question: Do you know of a PowerShell command that would also analyze the size of each individual mailbox and factor that in when assigning a database withing the DAG?
Thank you,
Brian
Hi Brian,
Thanks for the comment. Yes the New-MoveRequest cmdlet will use this automatic mailbox distribution logic when you do not specify a database using the TargetDatabase parameter.
I’m not aware of any existing scripts that will move a mailbox based on its size, but if you want to give me more details I can try to give you some ideas.
Hi Mike,
That’s what I had thought regarding individual mailbox size as a bit of googling had turned up empty. What we plan on doing then is to use the script below, and after a given number of mailboxes have been moved, check to see if any databases are reaching our threshold level. If so, we’ll so as you also mentioned, by suspending them from the pool.
-Brian
Set-AdServerSettings -ViewEntireForest $True
$file = Read-Host “Enter File Path for list of users. Example: C:\Scripts\File.txt”
$batch = Read-Host “Enter Batch Name for easy tracking of move requests. Example: Batch001″
$list = get-content $file
$DB = @{}
foreach ($mailbox in $list) {New-MoveRequest -Identity $mailbox -TargetDatabase $DB –baditemlimit 100 -BatchName $Batch | %{
$DB[$_.database] = $DB[$_.database] + 1
}
}
Get-MoveRequest -Batchname $batch
Write $DB
Yeah that looks like that would work…
If you need to you could use the Exchange_Mailbox WMI class to grab the 2003 mailboxes sizes.
For example, grab all mailboxes larger than 2gb:
$largeMailboxes = Get-WmiObject -NameSpace Root\MicrosoftExchangeV2 -Class Exchange_Mailbox -ComputerName ex2003server | ?{$_.size -gt 2000000}
Then you can see how many mailboxes are in the collection and the total size:
$largeMailboxes | Measure-Object size -sum | select count,sum
Obviously that’s a rough estimate of the total size it will actually be on the other side depending on a number of factors, but if that meets your requirements you can move them in a batch:
$largeMailboxes | %{New-MoveRequest -Identity $_.legacydn -TargetDatabase DB1 -BadItemLimit 100 -BatchName LargeMailboxes}
So, not a full blow script here, but maybe those examples can give you some more ideas.
Hi,
Excellent article, thank you for taking the time to write it. Once quick question, is there any documentation on how the provisioning procesess decides on malibox location? Is it a simple round robin between availble servers in the same site, or does it look at any statisitics such as iops or such?
Yeah, this was published a few months after I wrote this post:
Understanding Automatic Mailbox Distribution
http://technet.microsoft.com/en-us/library/ff477621.aspx
1. Exchange retrieves a list of all mailbox databases in the Exchange 2010 organization.
2. Any mailbox database that’s marked for exclusion from the distribution process is removed from the available list of databases. You can control which databases are excluded.
3. Any mailbox database that’s outside of the database management scopes applied to the administrator performing the operation is removed from the list of available databases.
4. Any mailbox database that’s outside of the local Active Directory site where the operation is being performed is removed from the list of available databases.
5. From the remaining list of mailbox databases, Exchange chooses a database randomly. If the database is online and healthy, the database is used by Exchange. If it’s offline or not healthy, another database is chosen at random. If no online or healthy databases are found, the operation fails with an error.