Exchange 2013 Maintenance mode

 

Now that Exchange 2013 service pack 1 is released, I believe it’s a good time to revisit this subject.

Why do I need Exchange 2013 Maintenance mode?

This is to ensure that your end users won’t be effected when performing any type of software/hardware maintenance on your exchange servers or when you are working on troubleshooting Exchange related problems.

To which server role does this procedure apply?

Maintenance mode should be used with Mailbox servers, both standalone mailbox servers and multi-role servers.

Is there a difference in putting a server into Maintenance mode for Database Availability Group Members and non-Database Availability Group Members?

Yes, DAG members will have extra steps involves moving all active databases off the server and blocking active databases from moving to the server. Also we need to ensure that all critical DAG support functionality that may be on the server (for example, the Primary Active Manager (PAM) role) is moved to another server and blocked from moving back to the server.

So what’s the procedure for putting Mailbox Servers that are not Database Availability Group Members into Maintenance mode?

1. Drain active mail queues on the mailbox server

Set-ServerComponentState <ServerName> -Component HubTransport -State Draining -Requester Maintenance

2. To help transport services immediately pick the state change run:

For Mailbox Server role:

Restart-Service MSExchangeTransport

If the server is a multi-role server(CAS/MBX) you need to run

Restart-Service MSExchangeTransport

Restart-Service MSExchangeFrontEndTransport

3. To redirect messages pending delivery in the local queues to another Mailbox server run:

Redirect-Message -Server <ServerName> -Target <MailboxServerFQDN>

Note: The target Server value has to be the target server’s FQDN and that the target server shouldn’t be in maintenance mode.

4. Since the server is not a DAG member, the only step left to put the server into maintenance mode is to run:

Set-ServerComponentState <ServerName> -Component ServerWideOffline -State Inactive -Requester Maintenance

Note: Closely monitor the transport queue before running the step above, queues at this stage should be empty or nearly empty, as we are disabling all server components, any mails still pending in the queues will have delay in delivery till the server is taken out from maintenance mode.

Andwhat’s the procedure for putting Mailbox Servers that are Database Availability Group Members into Maintenance mode?

1. Drain active mail queues on the mailbox server

Set-ServerComponentState <ServerName> -Component HubTransport -State Draining -Requester Maintenance

2. To help transport services immediately pick the state change run:

For Mailbox Server role:

Restart-Service MSExchangeTransport

If the server is a multi-role server(CAS/MBX) you need to run

Restart-Service MSExchangeTransport

Restart-Service MSExchangeFrontEndTransport

3. To redirect messages pending delivery in the local queues to another Mailbox server run:

Redirect-Message -Server <ServerName> -Target <MailboxServerFQDN>

Note: The target Server value has to be the target server’s FQDN and that the target server shouldn’t be in maintenance mode.

4. To prevents the node from being and becoming the PAM, pause the cluster node by running

Suspend-ClusterNode <ServerName>

5. To move all active databases currently hosted on the DAG member to other DAG members, run

Set-MailboxServer <ServerName> -DatabaseCopyActivationDisabledAndMoveNow $True

6. Get the status of the existing database copy auto activation policy, run the following and note the value of DatabaseCopyAutoActivationPolicy, we will need this when taking the server out of Maintenance in the future

Get-MailboxServer <ServerName> | Select DatabaseCopyAutoActivationPolicy

To prevent the server from hosting active database copies, run

Set-MailboxServer <ServerName> -DatabaseCopyAutoActivationPolicy Blocked

7. To put the server in maintenance mode run:

Set-ServerComponentState <ServerName> -Component ServerWideOffline -State Inactive -Requester Maintenance

Note: Closely monitor the transport queue before running the step above , queues at this stage should be empty or nearly empty, as we will be disabling all server components, any mails still pending in the queues will have delay in delivery till the server is taken out from maintenance mode.

 

How can I verify that the server is into Maintenance mode?

To verify the server has been placed into maintenance mode, run:

Get-ServerComponentState <ServerName> | ft Component,State –Autosize

All components should show “Inactive” except for Monitoring and RecoveryActionsEnabled

clip_image001

How do I take the sever Servers out of Maintenance Mode?

For Mailbox Servers that are not Database Availability Group Members

1. `` Run

Set-ServerComponentState <ServerName> -Component ServerWideOffline -State Active -Requester Maintenance

2. `` To help transport services immediately pick the state change run:

Restart-Service MSExchangeTransport

If the server is a multi-role server (CAS/MBX) you need to run

Restart-Service MSExchangeTransport

Restart-Service MSExchangeFrontEndTransport

 

For Mailbox Servers that are Database Availability Group Members

1. To designate that the server is out of maintenance mode and be able to resume its previous tasks, run:

A. Set-ServerComponentState <ServerName> -Component ServerWideOffline -State Active -Requester Maintenance

B. `` Resume-ClusterNode <ServerName>

C. ``Set-MailboxServer <ServerName> -DatabaseCopyActivationDisabledAndMoveNow $False

D. ``Set-MailboxServer <ServerName> -DatabaseCopyAutoActivationPolicy Unrestricted

Note: If the activation policy value was set to blocked before you started Maintenance, you must skip “D”

E. Set-ServerComponentState <ServerName> -Component HubTransport -State Active -Requester Maintenance

2. `` To help transport services immediately pick the state change run:

Restart-Service MSExchangeTransport

If the server is a multi-role server (CAS/MBX) you need to run

Restart-Service MSExchangeTransport

Restart-Service MSExchangeFrontEndTransport

How can I verify that the server is out of Maintenancemode?

To verify the server is not maintenance mode, run:

Get-ServerComponentState <ServerName> | ft Component,State –Autosize

All server components should show as “Active”

 

Can I automate Maintenance mode with a script?

Yes you can, actually Michael van Horenbeeck. Has leady written two scripts that can start and stop Maintenance mode, as mentioned by the script author, these scripts are provided “as-is” and are to be used on your own responsibility. Please use with caution and always test them before use.

References:

Comments

  • Anonymous
    January 01, 2003
    Great article, Thanks
  • Anonymous
    January 01, 2003
    Link updated , thanks Adaz
  • Anonymous
    May 12, 2014
    Should we put a CAS into maintenance mode? It is only a CAS not a mailbox.
  • Anonymous
    July 17, 2014
    That is a ridiculous amount of steps to perform. MS: Create a an easy button for this please. Thanks.
  • Anonymous
    August 15, 2014
    yeah - step 5 in the 'put dag member in maint mode' above:

    Set-MailboxServer -DatabaseCopyActivationDisabledAndMoveNow $True

    didn't work for me. I had to manually activate the passive copy on another server.
  • Anonymous
    September 04, 2014
    This saved my bacon, nothing like this in CU update procedures! Excellent! Big Thanks
  • Anonymous
    September 05, 2014
    What about moving the databases back to the server? I have a replayqueuelength=1 on the server that was in maint mode. When and how is it safe to move the active databases back to this server?
  • Anonymous
    September 05, 2014
    shouldn't you tell people to put the hubtransport back into an active state after maint. I learned the hard way after I started to do maint on the last server in my environment...no email.
  • Anonymous
    September 05, 2014
    nevermind on my previous post, I overlooked it.
  • Anonymous
    November 12, 2014
    "That is a ridiculous amount of steps to perform. MS: Create a an easy button for this please. Thanks."

    I agree, how is this not built into EAC yet?
  • Anonymous
    January 23, 2015
    That is a ridicoulus amount of steps to perform. Microsoft why didn't you provide one simple script for this, as it was available in Exchange 2010?

    This is another whitness about the quality of Software Microsoft is SELLING to his Customers.

    Shame on you
  • Anonymous
    January 26, 2015
    thank you for the informative post ! highly appreciated
  • Anonymous
    February 16, 2015
    The comment has been removed
  • Anonymous
    February 27, 2015
    Please update the Michael van Horenbeeck link, because that's broken.
    Here is the updated one:
    http://vanhybrid.com/2013/11/28/script-putting-exchange-server-2013-into-maintenance-mode/
  • Anonymous
    April 17, 2015
    The comment has been removed
  • Anonymous
    July 01, 2015
    Good one Nawar, very useful.
  • Anonymous
    August 05, 2015
    A couple of months ago I had a request from a customer to change the ip addresses of all their Exchange
  • Anonymous
    January 18, 2016
    Thank you a lot. A very helpful article
  • Anonymous
    January 27, 2016
    The link to Michael's blog is broken again. The article has been moved to http://vanhybrid.com/2015/07/20/script-putting-exchange-server-2013-into-maintenance-mode/.
  • Anonymous
    February 03, 2016
    Great post, just doing 2007 to 2013 with Dag so this information is invaluable. Many thanks for the information
  • Anonymous
    February 14, 2016
    the Michael van Horenbeeck link is broken again. please update it.
  • Anonymous
    March 02, 2016
    Here are the set of steps to go through, to ensure the Exchange 2010 Service Pack upgrades or the Exchange
  • Anonymous
    June 27, 2017
    Very shortly this website will be famous amid all blogging visitors,due to it's pleasant articles