Anavem
Languagefr
How to Put Exchange Server in Maintenance Mode Using PowerShell

How to Put Exchange Server in Maintenance Mode Using PowerShell

Learn to safely place Exchange Server into maintenance mode using PowerShell commands for draining services, redirecting messages, and handling DAG configurations before performing updates or maintenance tasks.

April 13, 2026 15 min
mediumexchange 8 steps 15 min

Why Put Exchange Server in Maintenance Mode?

Putting an Exchange Server into maintenance mode is a critical procedure that ensures safe server maintenance without disrupting email services for your organization. Whether you're installing Cumulative Updates, applying security patches, performing hardware maintenance, or troubleshooting issues, proper maintenance mode procedures prevent data loss and service interruptions.

Exchange Server maintenance mode involves systematically draining services, redirecting mail flow, and safely taking the server offline while maintaining business continuity. This process is especially important in Database Availability Group (DAG) environments where multiple servers work together to provide high availability.

What Makes Exchange Server Maintenance Mode Complex?

Unlike simple service restarts, Exchange maintenance mode requires careful orchestration of multiple components. The HubTransport component must be drained to stop accepting new messages, existing messages need redirection to other servers, and in DAG configurations, active database copies must be moved to healthy members. The ServerWideOffline component acts as the final switch that takes the server completely out of service.

Modern Exchange environments, including Exchange Server Subscription Edition (SE) as of 2026, maintain the same core maintenance procedures established in Exchange 2016 and 2019. However, the complexity increases in hybrid environments where on-premises servers integrate with Exchange Online, requiring additional considerations for mail routing and coexistence.

What Will You Learn in This Tutorial?

This tutorial walks you through the complete process using PowerShell commands that work across Exchange 2016, 2019, and Subscription Edition. You'll learn to safely drain transport services, handle DAG configurations, redirect message queues, and verify that your maintenance procedures completed successfully. We'll also cover common pitfalls and provide verification steps to ensure your Exchange environment remains healthy throughout the maintenance process.

Implementation Guide

Full Procedure

01

Verify Current Server State and Prerequisites

Before putting your Exchange server into maintenance mode, check the current component states and ensure you have the proper permissions and environment setup.

Open Exchange Management Shell as an administrator and run the following command to check the current server component states:

Get-ServerComponentState -Identity ExchangeServer01

This command displays all components and their current states. You should see components like HubTransport, ServerWideOffline, and others in 'Active' state before maintenance.

Next, verify your Exchange server version and role:

Get-ExchangeServer -Identity ExchangeServer01 | Select-Object Name, AdminDisplayVersion, ServerRole

If you're working with a Database Availability Group (DAG), check the DAG status:

Get-DatabaseAvailabilityGroup | Get-MailboxServer | Where-Object {$_.Name -eq "ExchangeServer01"}
Pro tip: Document the current state by exporting the component status to a file: Get-ServerComponentState -Identity ExchangeServer01 | Export-Csv C:\Temp\PreMaintenance-ComponentState.csv

Verification: Confirm all components show 'Active' state and note any existing 'Draining' or 'Inactive' components that might indicate ongoing issues.

02

Drain the HubTransport Component

The first step in maintenance mode is to drain the HubTransport component, which stops the server from accepting new messages while allowing existing messages to be processed.

Execute the following command to set HubTransport to draining state:

Set-ServerComponentState -Identity ExchangeServer01 -Component HubTransport -State Draining -Requester Maintenance

This command tells Exchange to stop accepting new messages but continue processing existing ones in the queue. The -Requester Maintenance parameter identifies why the component state was changed.

Monitor the transport queues to see the draining process:

Get-Queue -Server ExchangeServer01

Wait for the queues to drain naturally, or if you need to expedite the process, restart the transport services:

Restart-Service MSExchangeTransport
Restart-Service MSExchangeFrontEndTransport
Warning: Restarting transport services will cause a brief interruption in mail flow. Only do this if you need to expedite the draining process.

Verification: Run Get-ServerComponentState -Identity ExchangeServer01 -Component HubTransport to confirm the state shows 'Draining'.

03

Redirect Remaining Messages to Another Server

After draining the HubTransport component, redirect any remaining messages in the queues to another Exchange server to ensure mail flow continues.

Identify a target server that can handle the redirected messages:

Get-ExchangeServer | Where-Object {$_.ServerRole -match "Mailbox" -and $_.Name -ne "ExchangeServer01"}

Redirect all messages from your maintenance server to the target server:

Redirect-Message -Server ExchangeServer01 -Target ExchangeServer02

This command moves all queued messages from ExchangeServer01 to ExchangeServer02. The process may take several minutes depending on the queue size.

Monitor the redirection progress:

Get-Queue -Server ExchangeServer01 | Where-Object {$_.MessageCount -gt 0}

You can also check specific queue details:

Get-Queue -Server ExchangeServer01 | Select-Object Identity, DeliveryType, Status, MessageCount, NextHopDomain
Pro tip: If you have multiple target servers, you can redirect to different servers based on queue types or use a load balancer to distribute the load evenly.

Verification: Confirm that message counts in queues are decreasing and eventually reach zero or near-zero for most queues.

04

Handle Database Availability Group (DAG) Configuration

If your Exchange server is part of a DAG, you need to suspend the cluster node and move active database copies to other DAG members before proceeding with maintenance.

First, suspend the cluster node to prevent it from participating in cluster operations:

Suspend-ClusterNode -Name ExchangeServer01

Next, move all active database copies away from the maintenance server and block automatic activation:

Set-MailboxServer -Identity ExchangeServer01 -DatabaseCopyActivationDisabledAndMoveNow $True

Block automatic database activation on this server:

Set-MailboxServer -Identity ExchangeServer01 -DatabaseCopyAutoActivationPolicy Blocked

Verify that all active databases have been moved away from the maintenance server:

Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | Where-Object {$_.MailboxServer -eq "ExchangeServer01" -and $_.Status -eq "Mounted"}

Check the overall DAG health after moving databases:

Get-MailboxDatabaseCopyStatus | Where-Object {$_.MailboxServer -ne "ExchangeServer01"} | Sort-Object DatabaseName
Warning: If you're running a two-node DAG, ensure the witness server is accessible before proceeding, as you'll lose quorum if both nodes go offline.

Verification: Confirm no databases show 'Mounted' status on ExchangeServer01 and all databases are healthy on other DAG members.

05

Set Server to Offline State

The final step in enabling maintenance mode is setting the ServerWideOffline component to Inactive, which effectively takes the server out of service for all Exchange operations.

Execute the following command to set the server offline:

Set-ServerComponentState -Identity ExchangeServer01 -Component ServerWideOffline -State Inactive -Requester Maintenance

This command sets the server to offline state, preventing it from handling any Exchange services including client connections, mail flow, and database operations.

Verify the server is now in maintenance mode by checking all component states:

Get-ServerComponentState -Identity ExchangeServer01

You should see ServerWideOffline as 'Inactive' and HubTransport as 'Draining'. Other components may show various states depending on your Exchange version.

For a comprehensive health check, you can use the Exchange Health Checker script:

# Download and run HealthChecker.ps1 from Microsoft GitHub
.\HealthChecker.ps1 -Server ExchangeServer01 -OutputFilePath C:\Temp\
Pro tip: Create a maintenance log entry documenting when maintenance mode was enabled, who enabled it, and the planned maintenance duration for audit purposes.

Verification: Confirm that ServerWideOffline shows 'Inactive' and the server is no longer receiving client connections or processing mail.

06

Perform Maintenance Tasks

With your Exchange server now safely in maintenance mode, you can perform your planned maintenance tasks such as installing Cumulative Updates, applying security patches, or performing hardware maintenance.

During maintenance, monitor the other Exchange servers to ensure they're handling the additional load properly:

# Check queue status on other servers
Get-ExchangeServer | Where-Object {$_.ServerRole -match "Mailbox" -and $_.Name -ne "ExchangeServer01"} | ForEach-Object {
    Write-Host "Checking queues on $($_.Name)"
    Get-Queue -Server $_.Name | Where-Object {$_.MessageCount -gt 10}
}

Monitor database status on remaining DAG members:

Get-MailboxDatabaseCopyStatus | Where-Object {$_.MailboxServer -ne "ExchangeServer01"} | Sort-Object DatabaseName | Format-Table DatabaseName, MailboxServer, Status, CopyQueueLength, ReplayQueueLength

If you're installing Exchange Cumulative Updates, the typical process involves:

REM Run the CU installer from elevated command prompt
ExchangeServer2019-KB5000871-x64-en.exe /mode:upgrade /IAcceptExchangeServerLicenseTerms

After completing maintenance tasks, verify that Exchange services are running properly:

Get-Service | Where-Object {$_.Name -like "*Exchange*" -and $_.Status -ne "Running"}
Warning: Do not exit maintenance mode until you've verified that all maintenance tasks completed successfully and Exchange services are running properly.

Verification: Ensure all planned maintenance tasks are completed and Exchange services are in their expected running state before proceeding to exit maintenance mode.

07

Exit Maintenance Mode and Restore Services

After completing your maintenance tasks, you need to reverse the maintenance mode process in the correct order to safely bring your Exchange server back online.

Start by setting the ServerWideOffline component back to Active:

Set-ServerComponentState -Identity ExchangeServer01 -Component ServerWideOffline -State Active -Requester Maintenance

If your server is part of a DAG, resume the cluster node:

Resume-ClusterNode -Name ExchangeServer01

Unblock database activation and allow automatic activation:

Set-MailboxServer -Identity ExchangeServer01 -DatabaseCopyActivationDisabledAndMoveNow $False
Set-MailboxServer -Identity ExchangeServer01 -DatabaseCopyAutoActivationPolicy Unrestricted

Reactivate the HubTransport component:

Set-ServerComponentState -Identity ExchangeServer01 -Component HubTransport -State Active -Requester Maintenance

Restart the transport services to ensure proper mail flow:

Restart-Service MSExchangeTransport
Restart-Service MSExchangeFrontEndTransport

Verify all components are back to Active state:

Get-ServerComponentState -Identity ExchangeServer01
Pro tip: Wait 10-15 minutes after exiting maintenance mode before testing client connectivity to allow all services to fully initialize and register with load balancers.

Verification: Confirm all server components show 'Active' state and the server appears healthy in Exchange Admin Center.

08

Verify Full Service Restoration

The final step is to thoroughly test that your Exchange server is fully operational and handling client connections and mail flow properly.

Test mail flow by sending a test message through the server:

# Test internal mail flow
$TestMailbox = "testuser@contoso.com"
Send-MailMessage -From "admin@contoso.com" -To $TestMailbox -Subject "Post-Maintenance Test" -Body "Testing mail flow after maintenance" -SmtpServer ExchangeServer01

Check that databases are mounting properly and accepting connections:

Get-MailboxDatabase | Where-Object {$_.Server -eq "ExchangeServer01"} | Get-MailboxDatabaseCopyStatus

Verify client connectivity by testing various protocols:

# Test connectivity to various Exchange services
Test-OutlookConnectivity -ProbeIdentity "OutlookMapiHttp.Protocol" -TargetResource ExchangeServer01
Test-WebServicesConnectivity -MailboxCredential (Get-Credential) -TrustAnySSLCertificate

Monitor transport queues to ensure normal mail flow:

Get-Queue -Server ExchangeServer01 | Where-Object {$_.MessageCount -gt 0} | Format-Table Identity, Status, MessageCount, NextHopDomain

Run a final health check using the Exchange Health Checker script:

.\HealthChecker.ps1 -Server ExchangeServer01 -OutputFilePath C:\Temp\PostMaintenance\

Compare the post-maintenance health report with your pre-maintenance baseline to identify any issues.

Pro tip: Keep monitoring the server for 24-48 hours after maintenance to catch any delayed issues that might not be immediately apparent.

Verification: Confirm that mail flow is working, clients can connect successfully, and all health checks pass without critical errors.

Frequently Asked Questions

How long does it take to put Exchange Server in maintenance mode?+
The process typically takes 15-30 minutes depending on your environment complexity and message queue sizes. Draining HubTransport can take 5-10 minutes, message redirection another 5-15 minutes, and DAG operations 5-10 minutes. Always allow extra time for verification steps and monitoring queue drainage before proceeding with actual maintenance tasks.
Can I put Exchange Server in maintenance mode without affecting mail flow?+
Yes, when done properly with multiple Exchange servers. The maintenance mode process redirects messages to other healthy servers, ensuring continuous mail flow. However, you need at least one other Exchange server to handle the redirected load. Single-server environments will experience mail flow interruption during maintenance.
What happens if I skip the HubTransport draining step in Exchange maintenance mode?+
Skipping HubTransport draining can cause message loss and delivery delays. New messages will continue arriving at the server even after you set it offline, potentially causing queue backlogs and failed deliveries. Always drain HubTransport first to ensure graceful message handling and redirection to healthy servers.
How do I troubleshoot Exchange Server maintenance mode if commands fail?+
Common issues include insufficient permissions, PowerShell version conflicts, and cluster connectivity problems. Ensure you're running Exchange Management Shell as administrator with Organization Management role. Use PowerShell 5.1 instead of PowerShell 7 for compatibility. For DAG environments, verify cluster services are running and network connectivity exists between nodes before attempting maintenance mode commands.
Is Exchange Server maintenance mode different for hybrid environments with Office 365?+
The core maintenance mode process remains the same for hybrid environments, but you should monitor mail flow to Office 365 during maintenance. Hybrid connectors may route messages through your on-premises servers, so ensure your mail routing topology can handle the server being offline. Test mail flow between on-premises and cloud mailboxes after completing maintenance to verify hybrid connectivity.

Discussion

Share your thoughts and insights

Sign in to join the discussion