AgentMM – A command line tool to place OpsMgr agents into Maintenance mode

Here’s a command line line tool I’ve written using C# (requires .Net Framework 3.0) to put OpsMgr agents into maintenance mode similar to that using the PowerShell script written by Boris (see & The utility places three objects into maintenance mode when requiring to physically power down a computer for maintenance. This is a requirement from the console too, which is a question which has been raised numerous times and is unfortunately not an easy streamlined task within the OpsMgr console. For example, if you need to power down a server for hardware upgrade or service pack upgrade, from the OpsMgr console you would need to perform the following steps to prevent OpsMgr alerting you that the machine was offline:

1) From the Monitoring space, Computers view you would select the computer and place it in maintenance mode. This places the Agent in maintenance mode but NOT the HealthService instance or HealthServiceWatcher instance. (So missing the next steps if the machine was shut down would produce an alert with description “The computer <agentFQDN> was not pingable” with path Microsoft.SystemCenter.AgentWatchersGroup\<agentFQDN>. This is in response to a 20022 OpsMgr Connector event logged on the RMS due to the HeathService on the agent failing to heartbeat and a resultant diagnostic using Win32_PingStatus.

2) From the Discovered Inventory node, choose the State Actions, Change Target type and from View Common Targets select Health Service. Choose the Health Service for the agent in step 1 and place it in Maintenance mode

3) From the Discovered Inventory node, choose the State Actions, Change Target type and from View All Targets select Health Service Watcher. Choose the agent name from list and place it in Maintenance mode.


Using these three steps you will avoid alerts when a computer is completely shut down. NOTE: Placing Management servers into maintenance mode while they are operational, especially the RMS is not recommended or supported. Placing the RMS into Maintenance mode will essentially unload the workflow responsible for ending maintenance mode, so you’ll find maintenance mode never ends (This is mention although briefly in the Online help under “Maintenance Mode in Operations Manager 2007”.


Alternatatively you can use the utility below to place individual agents into maintenance mode when those agents are to be completely shutdown. AgentMM is an unsupported utility, you use at your own risk.

9/19 – A few issues I’ve found or had reported with this version: 1) OpsMgr Administrator rights are required to use AgentMM. If you use the admin console you would need minimally Operator rights. I’ll attempt to sort this out. 2) the domain\username for remote connections does require a backslash delimitter.

Here’s the command line help:


This utility can be used to place an agent in maintenance mode when that agent is to be taken offline (shut down) completely.
The Agent, the HealthService and the HealthServiceWatcher are placed into maintenance mode by AgentMM allowing the agent to be shut down without alerts being generated.

Command line usage to begin maintenance mode :
AgentMM [/S[erver] <sdkservername> domain/user] <AgentFQDN> <Comment> <Reasoncode> <MMStartDateTime> <MMEndDateTime> [/Test]
/S[erver] <sdkservername> domain\user – Are optional. Allows maintenance mode to be issued remotely. See DLL’s required below.
<AgentFQDN> – Is the fully qualified domain name of the agent to be placed in maintenance mode
<Comment> – Is a comment on why the agent is being placed into maintenance mode. Delimit with ” for comments including spaces
<Reasoncode> – Is an integer valid from the list of reasons list below
MMStartDateTime is a date and time to start maintenence mode. This is entered in short date/time format for your locale. e.g. “09/12/07 17:35”. Delimit with “
MMEndDateTime is a date and time to end maintenence mode. This is entered in short date/time format for your locale. e.g. “09/12/07 18:50″. Delimit with ”

Command line usage to end maintenance mode :
AgentMM [/S[erver] <sdkservername> domain/user] /Stop <AgentFQDN>

Shortcuts to usage:
MMStartDateTime can be entered using the word Now to signify the current date/time.
MMEndDateTime can be entered using an offset in Minutes or Hours from the MMStartDateTime. Use +30m for example to schedule a 30 minute window. Use +6h for example for schedule a 6
hour window.

List of Reasoncode values (0-14):
0 = ApplicationInstallation (An application is installed.)
1 = ApplicationUnresponsive (An application is unresponsive.)
2 = ApplicationUnstable (An application is unstable.)
3 = LossOfNetworkConnectivity (A loss of network connectivity has occurred.)
4 = PlannedApplicationMaintenance (Planned application maintenance.)
5 = PlannedHardwareInstallation (Planned hardware installation.)
6 = PlannedHardwareMaintenance (Planned hardware maintenance.)
7 = PlannedOperatingSystemReconfiguration (Planned operating system reconfiguration.)
8 = PlannedOther (Another planned reason not listed in this enumeration.)
9 = SecurityIssue (A security issue.)
10 = UnplannedApplicationMaintenance (Unplanned application maintenance.)
11 = UnplannedHardwareInstallation (Unplanned hardware installation.)
12 = UnplannedHardwareMaintenance (Unplanned hardware maintenance.)
13 = UnplannedOperatingSystemReconfiguration (Unplanned operating system reconfiguration.)
14 = UnplannedOther (Another unplanned reason that is not listed in this enumeration.)

Example of usage:
AgentMM 0 “Installing Service Pack 2”  Now +45m
The command above schedules maintenance mode to begin for agent ServerX1, specifying a reason as ApplicationInstallation, lasting 45 minutes
AgentMM /S OpsMgrRMS contoso\opsmgradmin 5 “Installing additional memory” Now “9/28/07 18:00:00”
The command above schedules maintenance mode to begin for agent ServerX1, specifying a reason as PlannedHardwareMaintenance.

What is test mode:
Adding a last parameter on the command line called /Test will not actually place any object in Maintenance mode.
Test mode will simply verify an agent with the support FQDN can be located and its current status together with a verification of command line parameters.

Not available in this version of AgentMM:
No ability to update Maintenance mode settings for an agent already in maintenance mode.
No ability to target groups at this time. Nice to have, maybe next time.

Remote connnections require the assemblies Microsoft.EnterpriseManagement.OperationsManager.DLL and Microsoft.EnterpriseManagement.OperationsManager.Common.DLL to be present.

Comments (16)

  1. Anonymous says:

    Happy new year to all! A few things I thought might be of interest! Maintenance mode Questions relating

  2. Anonymous says:

    I’d like to say “great tool” however I have been unable to successfully run it yet. I’m getting the following error when I run it:

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.EnterpriseManagement.OperationsManager, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

    File name: ‘Microsoft.EnterpriseManagement.OperationsManager, Version=6.0.4900.0, Culture=neutral,  PublicKeyToken=31bf3856ad364e35’ at AgentMM.AgentMM.Main(String[] args)

    WRN: Assembly binding logging is turned OFF.

    To enable assembly bind failure logging, set the registry value  [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.

    Note: There is some performance penalty associated with assembly bind failure logging.

    To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].

    Any assistance with this issue would be greatly appreciated.


    Cliveea – You will need the SDK binaries Microsoft.Enterprisemanagement.OperationsManager.dll and Microsoft.EnterpriseManagement.OperationsManager.Common.dll copied to the same folder as Agentmm. You can find these in the SDK Binaries folder beneath the Opsmgr install on the Management Server.

  3. Anonymous says:

    Summary This document will provide guidance to online links, resources, tools and blogs to assist in

  4. Anonymous says:

    There are so many tools currently developed that it is hard to know where to find them. Here is a list

  5. Anonymous says:

    There are many articles that talk about maintenance mode in System Center Operations Manager 2007. Topics

  6. Anonymous says:

    Happy new year to all! A few things I thought might be of interest! Maintenance mode Questions relating

  7. Anonymous says:

    So you have a simple case where a server operator needs to perform some maintenance and he does not have

  8. Anonymous says:

    At day 2 one of the sessions I followed covered the future of opsmgr. They announced that at the end

  9. Anonymous says:

    If you open the properties of this alert rule, you’ll see that the configuration data source scans the

  10. Anonymous says:

    The KB discussing the behaviour of maintenance mode when

  11. Anonymous says:

    &#160; Voici une liste de liens trés pratique sur tous les sujets SCOM , installation , configuration…

  12. Anonymous says:

    Main Downloads page (catalog, documentation)

  13. Anonymous says:

    This is a very useful tool!!  Nice job!!  In the next version, is there anyway that you can incorporate the password being passed on command line?  That way, I can write some other scripts and a GUI around this utility and get the username and password from the beginning…


  14. Anonymous says:

    Clive Eastwood , from Microsoft, has released a very nice maintenance mode tool for Opsmgr. With this

  15. Anonymous says:

    1. How can an agent be placed in maintenance mode from the command line? What are the other options for