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 http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/06/so-what-is-in-maintenance-mode.aspx & http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/30/stoping-maintenance-mode.aspx). 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 belowMMStartDateTime 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 6hour 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 ServerX1.contoso.com 0 "Installing Service Pack 2" Now +45mThe command above schedules maintenance mode to begin for agent ServerX1, specifying a reason as ApplicationInstallation, lasting 45 minutesAgentMM /S OpsMgrRMS contoso\opsmgradmin ServerX1.contoso.com 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.