Attached is a script that takes a group and puts all the computers in the group (as well as the health service and the healthservice watcher) into maintenance mode.

Here is how you can run the script from the command line to start or stop maintenance mode (without launching powershell.exe)

One of the uses of this script is when you deploy hotfixes to a large number of servers. You can also very easily use Task Scheduler to run this script on a regular basis for your maintenance windows.

Starting MM - powershell "c:\GroupMM.ps1" -groupName:'All Computers' -hours:10 -rmsServerName:'localhost' -startMM:$true

 

Ending MM - powershell "c:\GroupMM.ps1" -groupName:'All Computers' -hours:10 -rmsServerName:'localhost' -startMM:$false