Exchange 2016 – using maintenance mode for patching a DAG member
When patching an Exchange 2016 server that is a member of a DAG (Database Availability Group) it is best to put the server into maintenance mode before doing so. This is easily done using a few PowerShell cmdlets:
- Drain the mail queues:
Set-ServerComponentState
EX16-01 -Component HubTransport -State Draining -Requester Maintenance - Restart services:
Restart-Service MSExchangeTransport
- Redirect messages to another server
Restart-Service MSExchangeFrontEndTransport
- Redirect messages to another server:
Redirect-Message -Server EX16-01.mydomain.local -Target ex16-02.mydomain.local
- Suspend the cluster node:
Suspend-ClusterNode EX16-01
- Move the databases to another DAG member:
Set-MailboxServer EX16-01 -DatabaseCopyActivationDisabledAndMoveNow $True
- Block the server from hosting the databases:
Set-MailboxServer EX16-01 -DatabaseCopyAutoActivationPolicy Blocked
- Put the server in maintenance mode:
Set-ServerComponentState EX16-01 -Component ServerWideOffline -State Inactive -Requester Maintenance
Once patching, or other maintenance, is complete, just reverse the process:
- Take the server out of maintenance mode:
Set-ServerComponentState EX16-01 -Component ServerWideOffline -State Active -Requester Maintenance
- Resume the cluster node:
Resume-ClusterNode EX16-01
- Allow database copy and activation:
Set-MailboxServer EX16-01 -DatabaseCopyActivationDisabledAndMoveNow $False
- Allow the server to host the databases:
Set-MailboxServer EX16-01 -DatabaseCopyAutoActivationPolicy Unrestricted
- Enable Hub Transport to allow connections:
Set-ServerComponentState EX16-01 -Component HubTransport -State Active -Requester Maintenance
- Restart services:
Restart-Service MSExchangeTransport
Restart-Service MSExchangeFrontEndTransport