Updated PowerShell Script - Maintenance Mode
I was recently e-mailed by a colleague regarding the maintenance mode PowerShell script that was originally released by Boris Yanushpolsky (found here) that worked great for RTM/SP1, but was failing when executed on an OpsMgr 2007 R2 agent managed system. In addition, the script was designed to place an object into maintenance mode for an hourly duration, not in minutes matching the setting in the Operations Console.
As you know, in Operations Manager RTM/SP1, we did not place the health service or health service watcher instance of the computer object into maintenance mode as one would expect, when you place a computer and its contained objects into maintenance mode. In Operations Manager R2, this was resolved and no longer requires you to perform this as a second step in the process.
The attached script has been updated to support automating the placement of computer objects into maintenance mode for Operations Manager R2, and now accepts the argument of minutes instead of hours for duration of maintenance. I am also in the process of updating the Maintenance Mode management pack that Brian Wren originally developed, and Andrzej Lipka (a former MCS Consultant from Poland) and myself modified with some additional features (see Andrzej's MP here and mine here) so you can leverage it for R2. I hope to have it completed and tested by this weekend, and submitted for review and release on https://www.opsmanjam.com the following week.
The command-line for executing the script is:
Starting MM - powershell "c:\MMode_R2.ps1" -groupName 'All Computers' -minutes 10 -rmsServerName RMSSERVER -startMM $true
Ending MM - powershell "c:\MMode_R2.ps1" -groupName 'All Computers' -minutes 10 -rmsServerName RMSSERVER -startMM $false
Suggestions and feedback are always welcome.