How to Use Move-ActiveMailboxDatabase Cmdlet?

Summary: When you have to move active mailbox databases to another server in DAG environment, you can use PowerShell cmdlet Move-ActiveMailboxDatabase. In this post, you’ll get to know how to use the Move-ActiveMailboxDatabase and the various parameters used with this command.


How to Use Move-ActiveMailboxDatabase Cmdlet?

When you have a setup of Exchange Server with the failover configuration of two or more servers using the Database Availability Groups (DAG), you will have multiple copies of the same database over several servers, depending on your setup. The system will automatically set the primary mailbox database. After the primary seeding process, it will create synchronization between the primary mailbox database and the secondary copies on the other member servers acting as passive copies.

If the primary server fails or there is an issue, you might have to move the active mailbox databases to another server so that there is no interruption of services and importantly, no risk of data loss. This process will shut down the primary database, switch over to the passive copy, set the passive copy as the primary database, and switch the old primary database as the passive copy. The process will check the database copies and also check the integrity of the passive copy before starting it as the primary copy. Such switchovers also happened periodically due to maintenance windows for the hardware, server, and Exchange Server administrators. The maintenance jobs would include the upgrade or replacement of hardware components from the server, network changes, operating system updates and restarts, and Exchange Server patches and restarts. This will ensure business continuity and disaster recovery in case the main server fails.

How to Use Move-ActiveMailboxDatabase Cmdlet?

The switchover process from one server to another can be done via the Exchange Management Shell (EMS) by using the PowerShell cmdlet Move-ActiveMailboxDatabase.

ActiveMailboxDatabase

If you want to move the database from one server to another, the simple command includes the source database and the destination server (which will be the primary server). Here’s the command:

Move-ActiveMailboxDatabase DB1 -ActivateOnServer SRV-MYC-002

Move-ActiveMailboxDatabase

This command will perform a switchover of the mailbox database DB1 to the mailbox server SRV-MYC-002. After the process is successfully completed, the server SRV-MYC-002 will host the active copy of the mailbox database DB1.

The above command will move a specific database in your Database Availability Group (DAG). If you have an issue or maintenance task on your server, you will want to move all your databases. So, the command can be modified to perform a switchover of all the active databases on your Exchange Server setup. The command can be executed as given below.

Move-ActiveMailboxDatabase -Server SRV-MYC-001

Move-ActiveMailboxDatabase-Server

The above command will perform the switchover process of the active mailbox databases from the active host which is specified in the command i.e., SRV-MY-001, to one or even more mailbox servers having a healthy copy of the databases in the specified server in the command.

Some parameters that you can use with this command

-ActivatePreferredOnServer: This will move the databases to other servers where the preferred server is on top of the list. For each mailbox database, you can specify the preferred mailbox server. This parameter will not just move the database to any healthy server, but to the preferred one only.

ActivatePreferredOnServer

-ActivateOnServer <ServerName>: This will activate all mailbox databases on the specified server, irrespective of the preference. If you would like to move all active mailbox databases to a specific server, you can use this parameter.

ActivateOnServer

-SkipActiveCopyChecks: This will skip the check if the current active database is currently seeding or not. If the current active database is seeding, this will cancel the process and the switchover is done instantly. Data loss can occur at this stage. So, it’s best that this parameter is used as a last resort or in an emergency.

SkipActiveCopyChecks

-WhatIf: This is one of the important parameters, especially if you are doing some maintenance on the server and you would need to ensure that all is fine before proceeding. It is recommended to run the parameter during a scheduled maintenance. It will make a simulation of the command without applying the changes. This will give assurance that when you run the command, nothing wrong will happen and no issues will occur. However, in an emergency or sudden server shutdown or failure, you don’t have the luxury of checking the process.

WhatIf

There are several other parameters to this PowerShell cmdlet. To know more, you can refer this Microsoft link – https://docs.microsoft.com/en-us/powershell/module/exchange/move-activemailboxdatabase?view=exchange-ps.

What to do if you encounter any issues?

If all goes well, all the mailbox databases or a specific database will be moved to the secondary server until you have made the necessary maintenance or fix the server from any issues that occurred.

Sometimes, you encounter issues during the move of the active copy, such as:

An Active Manager operation failed. Error The database action failed. Error: An error occurred while trying to validate the specified database copy for possible activation. Error: Database copy DB1 on server SRV-MYC-002 has a copy queue length of 1243576076854322426 logs, which is too high to enable automatic recovery.

Most of the issues may occur due to corrupted log files, missing logs, corruption in the passive database, or any other damage that might have occurred during a sudden power loss of the active or secondary server. In such cases, applications such as Stellar Repair for Exchange can come in handy. The application can help you to get out of any sticky situation with minimum downtime and no data loss. It can open corrupt Exchange Server database and export the data granularly to PST and other file formats. Stellar Repair for Exchange can also export mailboxes directly from a damaged database to a live Exchange Server database or Office 365 tenant with no issues.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.