FAQ 000160 – How to properly perform maintenance on an Exchange DAG (reboot me softly)

This article applies to:

Exchange 2016

This article describes how to properly perform a maintenance procedure on a 2 node Exchange Database Availability Group (DAG).

You will typically need this in order to perform maintenance work like hardware installation, patching, software upgrades and similar, where it is necessary to shut down or reboot an Exchange machine that is part of a DAG.

For this purpose Microsoft delivers 3 PowerShell scripts as a part of your Exchange installation :


Those scripts will automate a lot of steps for you. For example, StartDagServerMaintenance.ps1 will set the Exchange server into maintenance mode, which will prevent that other servers in the DAG, attempt a database failover onto the maschine where you are currently performing maintenance work. Also all active databases will be moved to the other node(s). And after the maintenance work is done, you will be able to automatically redistribute database with the RedistributeActiveDatabases.ps1 script based on the configured activation preference.

Those scripts are located in the Exchange scripts folder. In Exchange PowerShell the path to this folder is preloaded in the variable $exscripts. Therefore you don’t need to memorise the langly path or to wonder around seaching for it (in case Exchange was installed in a non-default path). In order to switch directly to Exchange scripts folder, just type the following command in the Exchange PowerShell window.

cd $exscripts

So here are the steps on how to perform maintenance on your Exchange 2016 DAG:

On Server1

cd $exscripts
.\StartDagServerMaintenance.ps1 -ServerName SERVER1 -OverrideMinimumTwoCopies

Do you maintenance work

.\StopDagServerMaintenance.ps1 -ServerName SERVER1

On Server2 (same process as on Server1)

cd $exscripts
.\StartDagServerMaintenance.ps1 -ServerName SERVER2 -OverrideMinimumTwoCopies

Do your maintenance work

.\StopDagServerMaintenance.ps1 -ServerName SERVER2

Now that maintenance work is done on both servers, all database copies are active on SERVER1 and we need to redestribute them back to server(s) where those belong. For that purpose you can execute the following script

.\RedistributeActiveDatabases.ps1 -DagName DAGNAME -BalanceDbsByActivationPreference

Additional tips:


In order to verify that everything went OK with the database moves, at any given time, you can use the following command.

Get-MailboxDatabaseCopyStatus -Server SERVER1 | Format-Table -Autosize
Get-MailboxDatabaseCopyStatus -Server SERVER2 | Format-Table -Autosize

On servers that are handling larger amount of data it can take some time until indexing service picks up. So if for example ContentIndexState shows any value other than Healthy, simply wait 10-15 minutes. As a last resort you can force the retry by simply restarting the Microsoft Exchange Search Service.


In this example we used the -OverrideMinimumTwoCopies switch with the StartDAGServerMaintenance.ps1 script. The script will by default make sure that there are at least 2 available copies of data available, before it attempts to move a database. Since we here have only 2 nodes during maintenance on one of those you will actually have only 1 active copy available during the maintenance. Therefore the usage of the switch -OverrideMinimumTwoCopies is necessary. In environments where you have 3 or more copies of a database, you can omit this switch.


When doing a redistribution of databases with the .\RedistributeActiveDatabases.ps1 script you will be asked to confirm every database move. If you are working in a large production evironment were you can have 50+ databases per server, this can be a bit annoying. There is however a posibility to change that within the script:

Go to line 113 / 114 …

 # If used, causes Moves to request confirmation
[switch] $Confirm = $true,

… and change the switch statement to false.

[switch] $Confirm = $false,

Now the moves will happen automatically without need to confirm every individual move.

About the Author:

Dejan Foro
Dejan Foro is founder and CEO of Exchangemaster GmbH. He lives in Zurich, Switzerland and is a dedicated specialist, with 25 years of professional work experience in IT. Before starting Exchangemaster GmbH he worked for 20 years as a system engineer and project manager with customers of all sizes across many industries: From small ISV startups and a NGO humanitarian organizations up to largest international corporations like Stryker, Swisscom, British Telecom and Nyrstar. He spent his entire career delivering Microsoft based infrastructure solutions with main focus on Active Directory and Exchange. During those years, he collected a valuable work experience on 7 Exchange generations (2016, 2013, 2010, 2007, 2003, 2000 and 5.5) and has delivered services to a user base of about 3.2 million mailboxes in on-premise, hybrid and Office 365 deployments. Beside working on customer projects, he is a regular speaker and expert at Microsoft conferences and user groups. As a Microsoft Certified Trainer he teaches Microsoft Official Curriculum courses to technical professionals around Europe. For his work he has received numerous awards. In 2005 he was the first member to be elected into the MCP Hall of Fame by Windows IT Pro Magazine readers choice (as 1 of 6 worldwide). From 2005-2017, Dejan has been awarded by Microsoft Corporation with the yearly Microsoft Most Valuable Professional award in area of Exchange for 12 years in a row (one of approximately 100 worldwide and the only 1 such in Switzerland).

Leave A Comment