By putting your Exchange server(s) into maintenance mode you are allowing the servers to stop processing all incoming mail and drain anything that is still in the pipeline.
Why would you do this? For 2 reasons. Updates (both Windows and CU's) and to redirect all traffic to other Exchange servers in your enviroment.
I personally run maintanance mode because I have 2 Exchange servers in DAG and want to redirect them. Best practice recommendations is to run this as well even with a single Exchange server to prevent any kind of dataloss.
To put an Exchange server in maintenance mode, you need to run several commands. I however am a very lazy man and created a dumb powershell script to do everything for me. Feel free to download it here
There are 2 scripts:
- Enable Maintenance
- Disable Maintenance
The names are self explanatory in what they do, run Enable to start your maintenance and run Disable when you are done.
The script is pretty easy to use. It asks which server needs to be put in maintenance mode and which one will take over and that is it.
The important commands used in the script are as follows:
- Set-ServerComponentState: There are two lines in the script, the start and the end. The first one drains the server, the second one tells the server to become inactive. It will put all services to stopped.
- Redirect-Message: This line redirects mail traffic to another exchange server, if you do not have a DAG environment you can comment or remove this line
- Suspend-ClusterNode: This line supends the server that is in maintanance from the cluster, this only applies if you have a DAG environment, feel free to comment or remove this line out.
- Set-MailboxServer: This line also only applies to an DAG environment, it will move active database copies to another available DAG server, the $true line will move it, the Blocked line will prevent the DB from becoming active during maintanence.
The disable maintanence has the same commands, but basically reverts all the changes made so the server will become active again.