Matt Goedtel on Operations Management

Posts in this blog are provided "AS IS" with no warranties, and confers no rights as specified in the Terms of Use

Updated PowerShell Script - Maintenance Mode

Updated PowerShell Script - Maintenance Mode

  • Comments 4
  • Likes

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 http://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.

Attachment: OM2007R2_MMode.zip
Comments
  • i am getting following message when i run the command, how to run the command?

    'Starting' is not recognized as an internal or external command,

    operable program or batch file.

  • Ravi,

    I need to update the command-line example above, the colon is not necessary after each argument and before the value of the argument.

  • What are the minimum permissions required to run this script?

    I'm setting this up as a Scheduled task and need to use a service account.

    Great script by the way!

    Thanks!

  • Joel,

    You need to be a member of the Operations Manager Admins group in order for the script to complete successfully.  

    Matt

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment