Applies from Exchange 2010 to Exchange 2019 versions
Switchover

A switchover is a scheduled outage of a database or server that is explicitly initiated by a cmdlet or by the managed availability system in Exchange Server. Switchovers are typically done to prepare for performing a maintenance operation (like monthly patching, Cumulative update, or hardware replacement).
Switchovers involve moving the active mailbox databases copy to another server in the database availability group (DAG). If no healthy target is found during a switchover, administrators will receive an error and the mailbox database will remain up or mounted.
So before doing any mailbox database switchover, makes sure that exchange mailbox database is/are in “Healthy” status. The switchover action will not end successfully if the database status found unhealthy.
To verify the healthy status of the database against any server, run the below command
Get-MailboxDatabaseCopyStatus -server <Servername> Example Get-MailboxDatabaseCopyStatus -server MBX2 :: This example returns the status for all database copies on the Mailbox server MBX2. The status results are also displayed in a list format.
Once the databases are found healthy in both active and passive servers then run the below command to switchover the mailbox databases from one server to another server(s)
Move-ActiveMailboxDatabase -Server <ServerName> Example Move-ActiveMailboxDatabase -Server MBX2 This example performs a server switchover for the Mailbox server MBX2. All active mailbox database copies on MBX1 will be activated on one or more other Mailbox servers with healthy copies of the active databases on MBX2.
Upon the databases are switched over to other server check the health status of the databases again using same Get-mailboxdatabasecopystatus
Get-MailboxDatabaseCopyStatus -server MBX2
To do the switch back of specific mailbox database on specific server, run the command Move-ActiveMailboxDatabase -Server <ServerName>
Move-ActiveMailboxDatabase “databaseName” -ActivateOnServer <ServerName> Move-ActiveMailboxDatabase DB1 -ActivateOnServer MBX1
Redistribution
Microsoft exchange architecture prefer the databases are evenly active across all the member servers in database availability group.
After an outage or planned scheduled activity in your exchange environment (Exchange 2010 or Exchange 2013 or Exchange 2016 or Exchange 2019) you may find the databases are no longer balanced across in our Database Availability Group.
Once the planned activities completed, you must redistribute the database to all member servers and do the post checks to confirm the environment healthy status
The database redistribution occurs based on the activation preference that you have configured in the environment.
Exchange Server 2010 Service Pack 1 shipped with a script called redistributeactivedatabases.ps1 which allows you to automatically redistribute mailbox databases to their first activation preference. The script can be found in the Scripts folder of the Exchange Server 2010 installation path, which by default would be C:\Program Files\Microsoft\Exchange\V14\Scripts.
Reviewing mailbox database based on Activation Preference Distribution
We can use the same script to review the current distribution of databases in the database availability group.
To look at the current database distribution use RedistributeActiveDatabases.ps1 with the -ShowDatabaseDistributionByServer switch as referred below:
.\RedistributeActiveDatabases.ps1 -DagName DAG1 -ShowDatabaseDistributionByServer
Redistribute Exchange Databases in Exchange Server Database Availability Group (DAG)
In order to evenly redistribute the mailbox databases in the DAG members use the resdistributeactivedatabases.ps1 with below switches
C:\Program Files\Microsoft\Exchange Server\V14\Scripts> .\RedistributeActiveDatabases.ps1 –DagName –BalanceDBsByActivationPreference -ShowFinalDatabaseDistribution -Confirm:$False
Here we used -Confirm:$false as we do not want to be prompted for confirmation on each mailbox database switchover carried out during the redistribution process.
Switches of redistributeactivedatabases.ps1 and its use cases
The RedistributeActiveDatabases.ps1 script accepts the following parameters:
Switch | Description |
---|---|
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. |