Football and Microsoft Exchange Servers have technically not a lot in common but if you would combine, these two subjects into one Person that would be Nawar Al-Janabi. A big football supporter and our GBS MEA Guru for Exchange server. Let´s join Nawar in this Blog post to explain us the “Exchange 2013 Maintenance mode”… Nawar, it´s kick-off time!


Why do we 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 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 have to perform some extra steps to move 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?

  • Drain active mail queues on the mailbox server

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

  • 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

  • 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.

  • 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.

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

  • Drain active mail queues on the mailbox server

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

  •  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

  • 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.

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

Suspend-ClusterNode <ServerName>

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

Set-MailboxServer <ServerName> -DatabaseCopyActivationDisabledAndMoveNow $True

  • To 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

  • 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

  

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

For Mailbox Servers that are not Database Availability Group Members

  •  First run

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

  • 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

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

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

    • Resume-ClusterNode <ServerName>

    • Set-MailboxServer <ServerName> -DatabaseCopyActivationDisabledAndMoveNow $False

    • Set-MailboxServer <ServerName> -DatabaseCopyAutoActivationPolicy Unrestricted

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

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

  • 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 Maintenance mode?

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 already 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:

 


Original content from Nawar Al-Janabi, posted by GBS MEA editor Aydin Aslaner.