Whether to install CU updates on Exchange Server 2019 /2016 or reboot the server, the Exchange Admin follows some steps to place Exchange server Node (DAG Mode Only) in maintenance mode.

This PowerShell Module helps you place your Exchange Server in maintenance mode easily and safely using only one line of code.

System Requirements:

  • Microsoft.Exchange.Management.PowerShell.SnapIn
  • FailoverClusters PowerShell Module
  • Run the PowerShell as an administrator
  • The Exchange Management shell should be installed on the computer.
  • PowerShell 5.1, using PowerShell 7, won’t work.

The EMM in the naming convention stands for Exchange Maintenance Mode.

Download Exchange Server 2016/2019 PS Maintenance Module

The PSModule is now hosted in PowerShell Gallery. To download it, just open PowerShell and type the following command

Install-Module -Name EmmExDAGModule

Versions and updates

3 – Jun 2023 / Version 2.2

This version has multiple updates to support organizations with multiple Exchange Servers and gives the flexibility to manage the options. Please read the Supported Cmdlets section for more information.

  • List Exchange certificate when running Test-EMMReadiness
  • Only shows the failed result for Database copy and replication health
  • Shows cluster best practices
  • Exchange Database move will check and confirm another health database before moving the database.
  • Updating queue moving issue.
  • 120 Second, wait for the DB Move to be removed.
  • Connect to the internet, get the latest version information, and show any known issues.
  • Uses Exchange Management Shell to load instead of adding PSSnapin
  • Minor issues in the reporting.

Feel free to check it from Microsoft PowerShellGallery.com

Lets work together in making this better. Feel free to send a Pull Request from my GitHub with the required update

Supported Cmdlets

To simplify the process, there are only three cmdlets:

Start-EMMDAGEnabled

Start the process of placing an exchange server in maintenance mode. The supported parameters are:

  • [string][Required] ServerForMaintenance: The server name you want to place in maintenance mode. This name can be a NetBIOS name or FQDN.
  • [string][Required] ReplacementServerFQDN: The server name will act as a replacement. This is only used for Queue Transfer, so all queued messages in ServerForMaintenance are transferred to ReplacementServerFQDN
  • [Switch] IgnoreQueue: Use this parameter to skip queue check and transfer. Use this option to accelerate the process if the messages in the queue are not essential and can remain queued in the Exchange server while it’s down.
  • [switch] IgnoreCluster: This option can be used by organizations with IP-Less DAG.
  • [switch] SkipDatabaseHealthCheck: This option forces database migration from one node to another by skipping multiple health checks, which include:
    • SkipClientExperienceChecks: Skip Catalog health, even if it was in a failed state.
    • SkipCpuChecks: Ignore CPU utilization.
    • SkipMaximumActiveDatabasesChecks
    • SkipMoveSuppressionChecks: Skip how many times the database migrated within an hour.

EMM moves each database using activation preference order.

Stop-EMMDAGEnabled

Start placing the server, which is in maintenance mode, back into production. This cmdlet works even if your exchange server was in maintenance mode manually or by using Start-EMMDAGEnabled. This cmdlet supports the following parameters:

  • [String][Required]ServerInMaintenance: the name of the Exchange Server is currently in maintenance mode.
  • [Switch]IgnoreCluster: This option can be used by organizations with IP-Less Cluster.
  • [ValidationSet]ServerActivationMode: Set the Mailbox Server DatabaseCopyAutoActivationPolicy to IntrasiteOnly or Unrestricted. The default is Unrestricted.

Test-EMMReadiness

The Test-EMMReadiness scans your Exchange Server environment configuration and status and reports the current state which includes the Exchanges Server Component state, Cluster state, Database Queue Length, Services Health, and other details.
This cmdlet also reports which server is good to be used for maintenance and which server is not. Also, in this report, you will know if any server remained in maintenance mode or had any components disabled. This cmdlet supports the following parameter:

  • [Switch]IgnoreCluster: This option can be used by organizations with IP-Less Cluster.

Read more about the manual process and how to enable or disable Exchange Server 2019 Maintenance Mode Step-By-Step here:
Enable Exchange 2019 Maintenance Mode
Disable Exchange 2019 Maintenance Mode

Before placing the server in maintenance mode, it’s recommended to start by running the Test-EMMReadiness cmdlet to get a good overview and understanding of the current environment.

Challenges and Possible Issues with Manual process

One quick example is, that an administrator can set Hubtransport in Drain Mode in all the nodes, and Exchange Server accepts it. But if a user sent a message, it will be stored in the draft folder with a header.

As there is no message or warning that tells the administrator no more HubTransport service is available. The problem will appear to the users.

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
Using the EMM module and its cmdlets helps in validating the Exchange environment and won’t place a server in maintenance mode if there is no other server capable of handling the load.

Enable Maintenance Mode on Exchange Server 2019 or 2016

For this tutorial, an Exchange Server 2019 named EX01 and EX02 are used.

Example 1: The command below will set EX01 in Maintenance Mode, the ReplacementServerFQDN is the server that will be used for Queue Redirection (if required)

Start-EMMDAGEnabled -ServerForMaintenance EX01 -ReplacementServerFQDN EX02.test.local

Example 2: The command below sets Ex01 in Maintenance Mode, the -IgnoreQueue skips the redirecting of the queue to another server, which keeps all the messages queued on the same server.

Start-EMMDAGEnabled -ServerForMaintenance EX01 -ReplacementServerFQDN Ex02.test.local -IgnoreQueue

When using the -IgnoreQueue switch, the ReplacementServerFQDN is ignored.

Example 3: The command below sets Ex01 in Maintenance Mode, and the -IgnoreCluster skips the Failover Cluster check, this is helpful for IP-Less DAG.

Start-EMMDAGEnabled -ServerForMaintenance EX01 -ReplacementServerFQDN Ex02.test.local -IgnoreCluster
Start-EMMDAGEnabled Execution results

Currently, the Cluster Management won’t consider the cluster quorum, only will check to see if other nodes are available and active.

Limitation to consider.

Before placing the server in maintenance mode, its good to have deep visibility on the server status, use the Test-EMMReadiness for a deeper insight

Stop-EMMDAGEnabled

Use the Sop-EMMDAGEnabled to disable the Maintenance Mode and set the server back to a production active state.

Stop-EMMDAGEnabled -ServerInMaintenance Ex01
Stop-EMMDAGEnabled Output
Stop-EMMDAGEnabled Output

Test-EMMReadiness

The Test-EmmReadiness don’t require any parameter to start.

This command will generate a full report about the Exchange infrastructure and list the Active and Inactive components, also run a few tests to give the administrator an overview of the Exchange Server Infrastructure.

Test-EMMReadiness

The Test-EMMReadiness command will do the following:

  • Pinging the -SourceServer and confirm its reachability
  • Test Web Services availability 80 and 443
  • List all Exchange Server certificates with the expiry date.
  • List some cluster configurations.
  • List all the Exchange Servers HubTransport, ServerWideOffline, and HighAvailability component with their state.
  • List the number of an active UP Cluster node and the non-active nodes other than Up
  • Check the DatabaseCopyActivationDisabledAndMoveNow and DatabaseCopyAutoActivationPolicy policies
  • List the number of failed services on each node, and show them if any.
  • Show the Databases with the number of CopyQueueLength and ReplayQueueLength
  • Run a Test-ReplicationHealth

To make the output shorter, EMM will only show the failed result if any from both Get-Mailboxdatabasecopy and Test-ReplicationHealth

Report of Exchange Server 2019 Environment
Report of Exchange Server 2019 Environment.

All these tests should give the Exchange Server Administrator a view of the server components and what might go wrong or be forgotten in the infrastructure. Also, it’s good to say that this command won’t change anything, it’s only listing the current configuration.

Test cases and behavior using Exchange Server 2019 / 2016

This section will showcase how the EMM PS module can save you from some unexpected issues:

No More Active HubTransport Server Component

In this case, the admin needs to set EX02 to maintenance mode, while EX01 HubTransport Server Component is already in Draining State, so If the admin used the EmmEXDag module it will show the following

EMM Module, will not continue as the check fail to find other Active Hubtransport Server
EMM Module, will not continue as the check fail to find other Active Hubtransport Server

The process will stop and inform the admin to make sure that other HubTransport Server Components are available to avoid service disturbing.

The same thing will be applied to ServerWideOffline Server Component

No More Mailbox Server with a Non-Blocking Policy

In this example, the other nodes are configured with MailboxServer DatabaseCopyAutoActivationPolicy to Block

The Script will confirm the availability of other nodes, if not it will stop
The Script will confirm the availability of other nodes, if not it will stop

A Report of one Server in maintenance and the other in Active state

The image below shows how the report looks like if one node is already in maintenance mode and the other node is Active, so in this case, EX01 is already in maintenance mode but EX02 is still active.

Report when One Node is already in maintenance
Report when One Node is already in maintenance.

EMM vs StartDagServerMaintenance.PS1

Both have the same purpose, making your Exchange Server ready to be offline without disturbing the mail flow, but there are some other practices I love to follow that the StartDagServerMaintenance.ps1 won’t do

If I wrote something wroge, feel free contact me and update me, maybe I missed something

FeatureEMM ModuleStartDagServerMaintenance
Hub transport
Server Component
Drain itNo
Redirect QueueRedirect to another NodeNo
Cluster NodeWill Pause the nodeOptional By Parameter
MailboxServer PolicyYesYes
Confirm the availability of other nodesYesNo
LoggingShowing progressNo
ReportsDetailed Report using Test-EMMReadinessBasic Reported by Get-MailboxServerRedundancy

Conclusion

The EMM PS Module will give you a lot of insight view and of what’s going on so you can have a better understanding of Exchange infrastructure components. Also, will help you to set your Exchange Server 2016/2019 Maintenance mode in one line only

I hope you like this post and the module, feel free if you want to contribute to this script, update it send it back with your name in the top comment of the PS Module, and will update the PSRepository.

5/5 - (2 votes)