Planning to install CU or perform server maintenance, there are specific procedures and steps to execute to make the Exchange Server 2019 ready for maintenance mode. This tutorial will explain all the required steps in detail.

Steps to Activate Maintenance Mode.

Log in to the Exchange Server 2019 that you want to enable maintenance mode. it’s also possible to use Powershell Remoting

Draining the HubTransport Component

Set-ServerComponentState -identity dev-ex -Component HubTransport -State Draining -Requester Maintenance

This will tell the HubTransport to drain and finish processing the messages it has and stop accepting any new messages.

we can confirm the result by running

Get-ServerComponentState -Identity dev-ex -Component Hubtransport 
The HubTransport Component is now in Drain Mode

Transferring the Queue to another Exchange Server

After we ensure that the Hubtransport is Draining, we will need to redirect the Queue message to another Exchange Server 2019. Please note that the Target must be in FQDN.

Redirect-Message -Server dev-ex -Target Server2.dev-test.local

Make sure that the Target server must be in FQDN format, then run Get-Queue command to ensure that the queue is empty.

Executing Get-Queue after Set-ServerComponentState might return an error related to HubTransport service is not started, even though it is up and working fine. Just give it one minute and the Queue will respond again, no worry.

Pausing Cluster Node

Suspend the Cluster node so the server won’t accept any failover requests.

Please ensure the availability of the FailoverClusters Powershell Module before executing the next command.

PS C:\> Suspend-ClusterNode dev-ex

Name                 ID    State                                                                                                                                                                                                                                 
----                 --    -----                                                                                                                                                                                                                                 
dev-ex               1     Paused                                                                                                                                                                                                                                

#Make sure that the Node is now Paused

Configuring MailboxServer Policies.

We need to move all the Mounted databases to another server. There are two important commands

Set-MailboxServer dev-ex -DatabaseCopyActivationDisabledAndMoveNow $true

The DatabaseCopyActivationDisabledAndMoveNow and according to Technet will prevent this server from mounting any DB as long as there are other healthy databases in your environment, and also will move the hosted mounted DB to another server.

The process of moving triggering the database move can take some time. It’s might not move at all after three or even five minutes.

If the database remains on the same server, perform a manual move.

Use the command below to check the number of mounted databases on this server. The return should be empty.

PS C:\> Get-MailboxDatabaseCopyStatus -Server Dev-ex | where {$_.status -like "Mounted"} | select Name,Status

If the result for the Get-MailboxDatabaseCopyStatus was empty, this means that the Mounted databases are moved to another server.

PS C:\> Get-MailboxServer dev-ex | select DatabaseCopyAutoActivationPolicy

DatabaseCopyAutoActivationPolicy
--------------------------------
Unrestricted

The other parameter is, DatabaseCopyAutoActivationPolicy, this command can hold are:

  • Blocked: Prevents a database activation on the server.
  • IntrasiteOnly: Allow activation on the same site.
  • Unrestricted: unrestricted activation, anywhere DR or HQ.

It’s a good practice to take note of the current value before executing the Set-MailboxServer, use this Get-MailboxServer to get the current DatabaseCopyAutoActivationPolicy setting

Remember, that the DatabaseCopyAutoActivationPolicy is a server related policy, and will only be applied on the server specified. so setting the DatabaseCopyAutoActivationPolicy to Block will only prevent the database from being mounted on the specified server DEV-EX only, it still can be mounted on other servers.

PS C:\> Set-MailboxServer dev-ex -DatabaseCopyAutoActivationPolicy Blocked

PS C:\> #Confirm the command by running 

PS C:\> Get-MailboxServer dev-ex | Select DatabaseCopyActivationDisabledAndMoveNow,DatabaseCopyAutoActivationPolicy

DatabaseCopyActivationDisabledAndMoveNow DatabaseCopyAutoActivationPolicy
---------------------------------------- --------------------------------
                                    True                          Blocked

Taking off the ServerWideOffline Component.

The last step to enable maintenance mode is to disable (Inactive) all Exchange Server Components ServerWideOffline, using the command

PS C:\> Set-ServerComponentState dev-ex -Component ServerWideOffline -State Inactive -Requester Maintenance

PS C:\> # To Confirm
PS C:\> Get-ServerComponentState -Identity dev-ex -Component ServerWideOffline
Server                Component         State   
------                ---------         -----   
dev-ex.Dev-Test.local ServerWideOffline Inactive

What Happens If I do this by mistake?

Move Database to a server with DatabaseCopyActivationDisabledAndMoveNow set to $True

if DatabaseCopyActivationDisabledAndMoveNow to $True, and an attempt was made to move and Mount the database on this server. Exchange Server refuses to move the mailbox database and shows the following message

Server “dev-ex.Dev-Test.local” is enabled for DatabaseCopyActivationDisabledAndMoveNow. Moving databases to such servers may be ineffective because the system will automatically attempt to move again as soon as a healthy copy is detected.

Operation will fail if the DatabaseCopyActivationDisabledAndMoveNow is $ture
Trying to move database to server with DatabaseCopyActivationDisabledAndMoveNow is $ture

All The HubTransport Component was Inactive

Let’s assume that the Administrator forgot the Hubtransport in Drain Mode in all the nodes, what is the expected behavior?
The Exchange Server will accept it. But if a user sends a message, the message remains in the draft folder with a header.

Your Message will be sent, But we’re not quite ready. Check back in a couple of minutes

This message will be stored in the Draft Folder

Things to consider

By now, you are ready to start your exchange server maintenance. If you use any Load balancer, just make sure you redirect the traffic to the other active node.

Also, before starting, ensure that other exchange servers are available with all their components.

What’s Next

Your server is now in maintenance mode. Check this post to see how to Take Exchange Server Out of Maintenance Mode.

You can fully automate the entire process and get detailed reports by using Exchange Maintenance Mode PowerShell Module. This module enables maintenance mode in only one line

Exchange Database Planner to help you migrate mailbox between databases for a better re-distribution. Check it out
PS-EX: redistribute Mailboxes from Large Exchange Database Smaller DB (Planner)

Rate this post