PowerShell

 

Exchange 2013 Maintenance Mode PowerShell Script

You can download the ExchangeMaintenanceMode.ps1.txt script (please rename it to the correct file extension) from my colleague Andreas Bode and me.

The script contains the following functions:

  • Checks which Exchange Server Role is used (CAS, Mailbox, Multi-Role)

  • Places the server into Maintenance Mode

  • Writes an email if the server cannot be placed into Maintenance Mode (you have to change the SMTP server settings and enable the appropriate function)

  • Writes an Application log entry if the server cannot be placed into Maintenance Mode (EventID 10001, Type “ERROR”)

The script automatically searches for the “partner server” to drain the transport queues and UM calls. For example, change the variables $DC1Identifier and $DC2Identifier for servers in different data centers. The first 4 lower case characters are required.
Use the script with the following calls:
.\ExchangeMaintenanceMode.ps1 -Mode Check -Server <SERVERNAME>
.\ExchangeMaintenanceMode.ps1 -Mode Start -Server <SERVERNAME>
.\ExchangeMaintenanceMode.ps1 -Mode Stop -Server <SERVERNAME>

The mode “Check” is only for manual checking, if the server is in Maintenance Mode or not.
Feel free to download and change the script!