Sample Agent Maintenance Mode 2012 MP

Attention! New version of this MP is available. See blog:

Every Operations Manager administrator will hit the maintenance mode problem some times. It is not always useful to only have the option setting the maintenance mode through the console or with the minimum of Operator role permissions – as it is defined in OpsManager.

So with 2007 we implemented a agent based maintenance mode solution (provided by our Microsoft consultant Jens Morawietz – thanks for that!). So every user, which logs on to a server will see a splash screen which enables the user to set the maintenance mode directly on the machine without the need of the console and without permissions in Operations Manager. One additional request was: being able to set the maintenance mode through script for using in scheduled tasks. One example is a regular offline backup which brings a service down and where no alerts should be created. So the solution also offers a Visual Basic script, that can be added to those tasks.

With the upgrade to Operations Manager 2012 we had to change the solution a bit (use SCOM 2012 cmdlets, changed to PowerShell, etc.). So I post the 2012 solution here.

Base functionality:

1. The maintenance mode splash screen (or the TriggerOM12MM.Instance.Event.vbs script) writes an event into the OperationsManager event log
2. A rule on the agent checks if this event occurs and creates an informational alert. (part of Sample.Agent.MaintenanceMode.MP)
3. A second rule on the agent checks if this event occurs and triggers a PowerShell write action on the assigned management server to start the maintenance mode. (part of Sample.Agent.MaintenanceMode.MP)


1 a. The maintenance mode splash screen

The script behind this splash screen is written in PowerShell. So each agent, which should use this functionality needs PowerShell 2.0 and the OpsManager shell installed (links!).

The user sets the duration, reason and a enters a comment. Then the user can decide if only maintenance mode should be set or also a shutdown or reboot of the machine should be initiated. If a shutdown or reboot should be started, then the script waits 60 seconds to give the workflow time setting the maintenance mode first.
As soon as the user hits enter (that initializes maintenance mode only) or one of the buttons, an informational event is written to the Operations Manager event log.

This window indicates, that the log entry was created:

Then the script waits up to 5 minutes and checks if there are new events with the id 1215 in the OpsManager event log which indicate that the agent started maintenance mode.

The script will show this window, if the server is set into maintenance successfully:

Or it will show this window, if the maintenance mode was not started within the 5 minutes wait time:

You need to distribute this splash screen separately to the management pack to all agents, that should use this functionality. We have used SCCM for that. You will find a folder called MM in the Zip file which is linked to my post on System Center Central (see bottom). Copy this to the agents C:\ drive and copy the contained OpsMgrmm Shortcut to the Desktop of all users or to the Startup folder in the Start Menu of all users.

I also recommend to change add your company logo to the folder and call it “logo.gif” and enter a correct email address to contact the Operations Manager administrators in the OpsMgrMM.ps1 line 264:

$objContact.Text =“Please contact for assistance.”

The shortcut starts the PowerShell script in a hidden shell with the execution policy “Remotesigned”. So you do not need to change the default execution policy.

1 b. The TriggerOM12MM.Instance.Event.vbs script

The script is also located in the C:\MM folder. It also writes the same event log entry as the Maintenance mode splash screen. The difference is, that you can also specify a class and an instance to be set into maintenance mode.

cscript TriggerOM12MM.INstance.Event.vbs <maintenance mode duration in mins> <comment for maintenance> <class> <instance>

cscript.exe TriggerOM12MM.Instance.Event.vbs 15 “Monthly server reboot.” “Microsoft.Windows.Server.2003.LogicalDisk” “C:”

If you want to set the a complete class with all instances into maintenance, then change it like this:
cscript.exe TriggerOM12MM.Instance.Event.vbs 15 “Monthly server reboot.” “Microsoft.Windows.Server.2003.LogicalDisk” “”

If you want to set the whole server into maintenance, then change it like this:
cscript.exe TriggerOM12MM.Instance.Event.vbs 15 “Monthly server reboot.” “” “”

The script waits 3 min and then ends. So the server has time to go through the workflow and set the maintenance mode.

If you have a regular task, that stops a resource then add the call of this script at the beginning of your command line and then go on with your steps.

Now we have to move to the Sample.Agent.MaintenanceMode.MP

Import this Mp into your Operations Manager 2012 environment. The management pack will create two rules and a Run as Profile.

Sample – Event Log Entry Triggers Alert Rule
Sample – Event Log Entry triggers Maintenance Mode Rule
=> Both rules are targetted to “Microsoft.Windows.OperatingSystem”, so they will run on all Windows computers.

Run as Profile:
Sample Operations Manager Administrator Run As Profile
=> Assign a Operations Manager administrator user to this profile!

2.  Sample – Event Log Entry Triggers Alert Rule

This rule checks for the event 997 in the Operations Manager event log on the agent and creates an informational alert.

Name: Sample Maintenance Mode 2012 – Maintenance Mode was Triggered On The Agent
Source:    Microsoft Windows Server 2008 R2 Standard
Full Path Name:    Servername\Microsoft Windows Server 2008 R2 Standard
Alert Rule:    Sample – Event Log Entry Triggers Alert Rule
Created:    8/2/2012 5:52:55 AM
Alert Description:
The maintenance mode was triggered on: Microsoft Windows Server 2008 R2 Standard . Event Description: TriggerOM12MM.Instance.vbs 1.1 : Start;15;PlannedOther;;;Test:domain\username;8/2/2012 5:52:55 AM.

3. Sample – Event Log Entry triggers Maintenance Mode Rule

This rule checks for the event 997 in the Operations Manager event log on the agent and starts a write action on the asigned management server.

<WriteAction ID=”WA” TypeID=”Sample.Agent.MaintenanceMode.EventlogEntryTriggersMM.WriteAction” Target=”SC!Microsoft.SystemCenter.ManagementServer”>

This write action is based on a PowerShell 2.0 script, so the management server also needs PowerShell 2.0 installed.

The write action itself uses the defined run as profile (Sample Operations Manager Administrator Run As Profile), where a user with Operations Manager administrator permissions needs to be assigned to. Otherwise the write action will not work!

<WriteActionModuleType ID=”Sample.Agent.MaintenanceMode.EventlogEntryTriggersMM.WriteAction” Accessibility=”Internal” RunAs=”Sample.Agent.MaintenanceMode.OpsMgrAdmin.RunAsProfile” Batching=”false”>

The write action will set the maintenance mode depending on how the event description looks like.

TriggerOM12MM.Instance.vbs 1.1 : Start;15;PlannedOther;;;Test:domain\username;8/2/2012 5:52:55 AM
<Will be ignored>;<Duration>;<Class>;<Instance>;<Comment>;<Will be ignored>

Here you can download the Zip file:

Post a comment or leave a trackback: Trackback URL.


  • pzerger  On August 3, 2012 at 1:17 am

    Natascia, it appears you tried to attach your MP to a blog post on Sytem Center Central. Please upload to the Management Pack Catalog at

    This will ensure your great pack is available along with all the other community MPs in the catalog.


    • opsmgrtipps  On August 3, 2012 at 7:09 am

      Hi Pete,
      thanks for this tipp. I am new in blogging, so I am glad to get this information from you. I have uploaded my mp to the MP Catalog on SystemCenterCentral and updated the link here.


  • Stefan Koell  On August 3, 2012 at 8:18 am

    Very nice. Thanks for sharing and greetings to germany…

  • Marcel Zehner  On March 28, 2013 at 1:34 pm


    I know I’m late 🙂 This is definitely a nice and useful MP. Thanks for sharing!


  • Thomas  On May 10, 2013 at 10:50 pm

    Hi Natascia,
    this a really great tool, this is exactly what i am search for. Is it possible to chance the .ps1 file that the button “Close waiting” is not visible? I tested with several changing in the script but i have not really know how in scripting.
    Thanks in advance.
    Best regards.

    • opsmgrtipps  On May 13, 2013 at 2:34 pm

      Hi Tom,

      you only need to comment out the line $Form.Controls.Add($btnStop). This line adds the button to the form.

      Kind regards,

  • Jeff  On April 23, 2014 at 9:00 pm

    This is great. Had something similar in SCOM 2007.
    Can you go into more detail on the Run As Profile, specifically in scenario’s where gateway’ed environments to untrusted forests are involved? More of a step by step for that area would be great.
    Also, I noticed a “FallBackMS” parameter that seems to be set to what I can assume is someone’s secondary management server. Is this parameter used and does it need to be set? Was I correct that its to identify a secondary MS?

    Thanks in Advance!

    • opsmgrtipps  On April 28, 2014 at 8:35 am

      Hi Jeff,

      The run as account must be a Scom administrator, it is used on a write action on the management server, so it does not effect the agents.
      The FallbackMs is used if a second management server is available to connect to the management group, of the first one does not respond.

      If you only have one, then you can enter the same server as FallbackMs.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: