If you have a DAG with multiple Mailbox servers and a lot of Mailbox databases it’s a good practice to regularly have a look at the distribution of the Mailbox database.
When you reboot a Mailbox server for example all active copies of Mailbox databases are moved to other Mailbox server but they are never moved back to their original location.
To create an evenly distribution Microsoft supplies a script called RedistributeActiveDatabases.ps1 that you can use to distribute the Mailbox databases across all Mailbox servers in the DAG.
This script is located in the $Exscripts directory (C:\Program Files\Microsoft\Exchange Server\V14\scripts or V15 if using Exchange 2013) and is run like this when distributing by using the Mailbox database activation preference:
.\RedistributeActiveDatabases.ps1 –DagName <<name>> –BalanceDbsByActivationPreference –confirm:$false
The RedistributeActiveDatabases.ps1 script accepts the following parameters:
- DagName – Specifies the name of the DAG you want to rebalance. If this parameter is omitted, the DAG of which the local server is a member is used.
- BalanceDbsByActivationPreference – Specifies that the script should move databases to their most preferred copy without regard to the Active Directory site.
- BalanceDbsBySiteAndActivationPreference – Specifies that the script should attempt to move active databases to their most preferred copy, while also trying to balance active databases within each Active Directory site.
- ShowFinalDatabaseDistribution – Specifies that a report of current database distribution be displayed after redistribution is complete.
- AllowedDeviationFromMeanPercentage – Specifies the allowed variation of active databases across sites, expressed as a percentage. The default is 20%. For example, if there were 99 databases distributed between three sites, the ideal distribution would be 33 databases in each site. If the allowed deviation is 20%, the script attempts to balance the databases so that each site has no more than 10% more or less than this number. 10% of 33 is 3.3, which is rounded up to 4. Therefore, the script attempts to have between 29 and 37 databases in each site.
- ShowDatabaseCurrentActives – Specifies that the script produce a report for each database detailing how the database was moved and whether it’s now active on its most-preferred copy.
- ShowDatabaseDistributionByServer – Specifies that the script produce a report for each server showing its database distribution.
- RunOnlyOnPAM – Specifies that the script run only on the DAG member that currently has the PAM role. The script verifies it’s being run from the PAM. If it isn’t being run from the PAM, the script exits.
- LogEvents – Specifies that the script logs an event (MsExchangeRepl event 4115) containing a summary of the actions.
- IncludeNonReplicatedDatabases – Specifies that the script should include non-replicated databases (databases without copies) when determining how to redistribute the active databases. Although non-replicated databases can’t be moved, they may affect the distribution of the replicated databases.
- Confirm – The Confirm switch can be used to suppress the confirmation prompt that appears by default when this script is run. To suppress the confirmation prompt, use the syntax -Confirm:$False. You must include a colon in the syntax. If you have a lot of Mailbox databases this is an interesting option, if you don’t set this you have to confirm all moves in the DAG manually.
You can also use the task scheduler to run this script on a regular basis, for example at 1 am to have a minimal impact on users.