Skip to 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 installing Exchange Server Cumulative Update/Exchange Server Security Update, we would like to get the Exchange Server EX01-2019 active again. So, let’s remove the server from maintenance mode.

Run Exchange Management Shell as administrator and run the commands.

Note: Only the first and last commands are necessary if the server is not a DAG member. 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-2019" -Component ServerWideOffline -State Active -Requester Maintenance

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

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

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

[PS] C:\>Set-ServerComponentState "EX01-2019" -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 "DAG01-2019" -BalanceDbsByActivationPreference -SkipMoveSuppressionChecks

Verify out of maintenance mode

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

The cluster node needs to have the state up.

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

Name      State Type
----      ----- ----
EX01-2019 Up    Node

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-2019"


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                    : 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-2019"

MailboxServer      Database           Result    Error
-------------      --------           ------    -----
EX01-2019          DB1                Success
EX01-2019          DB2                Success
EX01-2019          DB3                Success
EX01-2019          DB4                Success
EX01-2019          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-2019" | Sort Name | Select Name, Status, Contentindexstate

Name          Status  ContentIndexState
----          ------  -----------------
DB1\EX01-2019 Mounted     NotApplicable
DB2\EX01-2019 Mounted     NotApplicable
DB3\EX01-2019 Mounted     NotApplicable
DB4\EX01-2019 Mounted     NotApplicable
DB5\EX01-2019 Mounted     NotApplicable

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-2019"

Server          Check                      Result     Error
------          -----                      ------     -----
EX01-2019       ClusterService             Passed
EX01-2019       ReplayService              Passed
EX01-2019       ActiveManager              Passed
EX01-2019       TasksRpcListener           Passed
EX01-2019       TcpListener                Passed
EX01-2019       ServerLocatorService       Passed
EX01-2019       DagMembersUp               Passed
EX01-2019       MonitoringService          Passed
EX01-2019       ClusterNetwork             Passed
EX01-2019       QuorumGroup                Passed
EX01-2019       FileShareQuorum            Passed
EX01-2019       DatabaseRedundancy         Passed
EX01-2019       DatabaseAvailability       Passed
EX01-2019       DBCopySuspended            Passed
EX01-2019       DBCopyFailed               Passed
EX01-2019       DBInitializing             Passed
EX01-2019       DBDisconnected             Passed
EX01-2019       DBLogCopyKeepingUp         Passed
EX01-2019       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-2019" | Select Name, DatabaseCopyAutoActivationPolicy

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

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

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

Another way to verify that Exchange Server is out of maintenance mode is to download and run the Exchange Health Checker PowerShell script.

[PS] C:\scripts>Get-ExchangeServer | ?{$_.AdminDisplayVersion -Match "^Version 15"} | .\HealthChecker.ps1; .\HealthChecker.ps1 -BuildHtmlServersReport -HtmlReportFile "ExchangeAllServersReport.html"; .\ExchangeAllServersReport.html

The below screenshot shows what Exchange Server is not in Maintenance looks like in the Exchange Health Checker report.

Take Exchange Server out of maintenance mode script

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. Sign in to your load balancer and set any virtual services you have to enable any connections to Server EX01-2019. Typically there would be SMTP and HTTPS virtual services. This will enable connections to Server EX01-2019.

Conclusion

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 also like Configure pagefile in Exchange Server. 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 9 Comments

  1. When running the command i get this

    “the operation could not be performed because no mailbox database is currently hosted on server”

    Yet ecp shows databases

  2. Hi,
    I have a very strange situation,
    two Exchange server in DAG, the first server
    holds all the databases, the second server I have found that It
    is in partial Maintenance state at least for a month!
    In the server exchange02 the DatabaseCopyAutoActivationPolicy is set to BLOCKED
    at least for a mounth!
    Everything else it is ok, the cluster node is UP
    The components are in Active state
    And the services are in Running

    In your opinion can I set the
    DatabaseCopyAutoActivationPolicy to ‘UNRESTRICTED’ without problems?
    The question is
    How long the DatabaseCopyAutoActivationPolicy (Exchange server 2013 in this case)
    can stay in BLOCKED state?
    Do you have any procedure, any link, any suggestion about it?
    thank you in advance for your articles very useful and professional

    1. Hi Alex,

      You can set the DatabaseCopyAutoActivationPolicy to UNRESTRICTED. But, before you do that, you might want to ask if there was a reason for doing that.

      If it’s set to BLOCKED, that’s because someone forgot to set it back to UNRESTRICTED, or they don’t want the databases automatically activated on this server. Instead, they want to activate the mailbox database manually.

  3. If I am just doing windows updates on one server at a time in my DAG (8 total, 4 DAG, 4 MS) why would I need to run below? Would this cause any other DAG databases to be moved if not on their current most preferred and cause any downtime for users?

    .\RedistributeActiveDatabases.ps1 -DagName “2016DAG” -BalanceDbsByActivationPreference -SkipMoveSuppressionChecks

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

  5. 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 *