skip to Main Content

Take Exchange Server out of maintenance mode

Suppose you have put the Exchange Server in maintenance mode and finished working on it. You like to take the Exchange Server out of maintenance mode. It’s good to have the Exchange Server back in production. Run the commands and verify if all is working as expected on the Exchange Server.

Take Exchange Server out of maintenance mode

After the update, we like to get the Exchange Server EX01 to be active again. Run Exchange Management Shell as administrator.

You can now remove the server from maintenance mode. Note: If the server is not a DAG member, only the first and last commands are necessary. If the server is a DAG member, you need to run all the commands. Use the database copy auto-activation policy value that was set on the server. The default is Unrestricted.

[PS] C:\>Set-ServerComponentState "EX01" -Component ServerWideOffline -State Active -Requester Maintenance

[PS] C:\>Resume-ClusterNode -Name "EX01"

Name        ID    State
----        --    -----
EX01        1     Up

[PS] C:\>Set-MailboxServer "EX01" -DatabaseCopyAutoActivationPolicy Unrestricted

[PS] C:\>Set-MailboxServer "EX01" -DatabaseCopyActivationDisabledAndMoveNow $false

[PS] C:\>Set-ServerComponentState "EX01" -Component HubTransport -State Active -Requester Maintenance

Rebalance Database Availability Groups

Throughout the update process, the database copies will move between DAG members. Return your active database copies to their most preferred DAG member. Use the PowerShell script supplied by Microsoft.

[PS] C:\>cd $exscripts
 
[PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts\>.\RedistributeActiveDatabases.ps1 -DagName "DAG1" -BalanceDbsByActivationPreference -SkipMoveSuppressionChecks

Verify out of maintenance mode

Verify if the Exchange Server EX01 is back up and running. Run the following commands.

The cluster node needs to have the state up.

[PS] C:\>Get-ClusterNode "EX01"

Name         ID    State
----         --    -----
EX01         1     Up

Check that the cluster node has the state up on all the Exchange Servers.

[PS] C:\>Get-ClusterNode

Check that all the required services are running.

[PS] C:\>Test-ServiceHealth "EX01"


Role                    : Mailbox Server Role
RequiredServicesRunning : True
ServicesRunning         : {IISAdmin, MSExchangeADTopology, MSExchangeDelivery, MSExchangeIS, MSExchangeMailboxAssistants, MSExchangeRepl, MSExchangeRPC, MSExchangeServiceHost,
                          MSExchangeSubmission, MSExchangeThrottling, MSExchangeTransportLogSearch, W3Svc, WinRM}
ServicesNotRunning      : {}

Role                    : Client Access Server Role
RequiredServicesRunning : True
ServicesRunning         : {IISAdmin, MSExchangeADTopology, MSExchangeMailboxReplication, MSExchangeRPC, MSExchangeServiceHost, W3Svc, WinRM}
ServicesNotRunning      : {}

Role                    : Unified Messaging Server Role
RequiredServicesRunning : True
ServicesRunning         : {IISAdmin, MSExchangeADTopology, MSExchangeServiceHost, MSExchangeUM, W3Svc, WinRM}
ServicesNotRunning      : {}

Role                    : Hub Transport Server Role
RequiredServicesRunning : True
ServicesRunning         : {IISAdmin, MSExchangeADTopology, MSExchangeEdgeSync, MSExchangeServiceHost, MSExchangeTransport, MSExchangeTransportLogSearch, W3Svc, WinRM}
ServicesNotRunning      : {}

Check that the required services are running on all the Exchange Servers.

[PS] C:\>Get-ExchangeServer | Test-ServiceHealth

Test the MAPI Connectivity.

[PS] C:\>Test-MAPIConnectivity -Server "EX01"

MailboxServer      Database           Result    Error
-------------      --------           ------    -----
EX01               DB1                Success
EX01               DB2                Success
EX01               DB3                Success
EX01               DB4                Success
EX01               DB5                Success

Test the MAPI Connectivity on all the Exchange Servers.

[PS] C:\>Get-ExchangeServer | Test-MAPIConnectivity

Get the result of the DAG Copy Status Health.

[PS] C:\>Get-MailboxDatabaseCopyStatus -Server "EX01" | Sort Name | Select Name, Status, Contentindexstate

Name      Status  ContentIndexState
----      ------  -----------------
DB1\EX01 Mounted            Healthy
DB2\EX02 Mounted            Healthy
DB3\EX01 Mounted            Healthy
DB4\EX02 Mounted            Healthy
DB5\EX01 Mounted            Healthy

Get the result of the DAG Copy Status Health on all the Exchange Servers.

[PS] C:\>Get-MailboxDatabaseCopyStatus * | Sort Name | Select Name, Status, Contentindexstate

Check the Replication Health.

[PS] C:\>Test-ReplicationHealth -Server "EX01"

Server     Check                      Result     Error
------     -----                      ------     -----
EX01       ClusterService             Passed
EX01       ReplayService              Passed
EX01       ActiveManager              Passed
EX01       TasksRpcListener           Passed
EX01       TcpListener                Passed
EX01       ServerLocatorService       Passed
EX01       DagMembersUp               Passed
EX01       MonitoringService          Passed
EX01       ClusterNetwork             Passed
EX01       QuorumGroup                Passed
EX01       FileShareQuorum            Passed
EX01       DatabaseRedundancy         Passed
EX01       DatabaseAvailability       Passed
EX01       DBCopySuspended            Passed
EX01       DBCopyFailed               Passed
EX01       DBInitializing             Passed
EX01       DBDisconnected             Passed
EX01       DBLogCopyKeepingUp         Passed
EX01       DBLogReplayKeepingUp       Passed

Check the Replication Health on all the Exchange Servers.

[PS] C:\>Get-DatabaseAvailabilityGroup | Select -ExpandProperty:Servers | Test-ReplicationHealth | Sort Name

Verify the Database Activation Policy is set to Unrestricted.

[PS] C:\>Get-MailboxServer "EX01" | Select Name, DatabaseCopyAutoActivationPolicy

Name         DatabaseCopyAutoActivationPolicy
----         --------------------------------
EX01                             Unrestricted

Verify the Database Activation Policy is set to Unrestricted on all the Exchange Servers.

[PS] C:\>Get-MailboxServer | Select Name, DatabaseCopyAutoActivationPolicy

Load balancer

Do you have the Exchange Server configured in a load balancer? Verify that the load balancer health checks have taken the server in the pool or marked it as online/active. If the load balancer does not automatically do this, manually mark the server as online/active. Log into your load balancer and set any virtual services you have to enable any connections to Server EX01. Typically there would be SMTP and HTTPS virtual services. This will enable connections to Server EX01.

Conclusion

In this article, you learned how to take the Exchange Server out of maintenance mode. It’s important to run the commands and check if all the services are healthy. It’s good to have a list of PowerShell commands before starting. The output needs to be positive.

Did you enjoy this article? You may like Pagefile Exchange 2013/2016 best practice PowerShell. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 4 Comments

  1. Hello Ali,
    I have 2 mail server and 2 CAS. my question do I have to run ADprep and Schema prep on all servers or just once on any server.

    Thank you,

    Nusrat Hussain

  2. If I set the redirect-message to EX02 when setting EX01 to maintenance, how would I go about redirecting back to EX01?

    Regards,

    1. Have a look at the first block. There are five commands.

      Do you have a DAG? Run all five commands (after that run the PS script in the second block)
      Don’t you have a DAG? Run the first and last command

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top