The argument could be made that this script is not something that has a practical use. One of my customers had a requirement to quickly (and gracefully) shut down an entire site of Exchange servers. I assume the scenario would be due to some kind of natural disaster or cooling issue in a datacenter. I am posting this because one of my customers had an actual need for it, and some of the techniques in this script could be applied to other scripts. I will leave the practicality of this script up to the reader.
The script will identify servers by site and optionally by server name as well. The script leverages WinRM to stop services remotely on multiple servers, so WinRM must be enabled and firewall rules must be opened. The advantage is this can be executed on any number of servers and should take generally around the same time to complete.
After the script identifies which servers need to be shut down, it will dismount any databases that are mounted and stop the cluster service on DAG nodes, as well as stopping the msExchangeADTopology service (and dependent services). Once all services are stopped, the script will initiate a shutdown of each server.
Here is the script in action:
As a reminder, all servers will need to be manually powered back on; in addition, all databases that were dismounted will need to be mounted after the servers are brought back online.
*Edit* – The script can be found here.