GUIDE, SCOM

Enabling SCOM Maintenance Mode from a Monitored Computer

System Center Operations Manager 2016 (SCOM) came out with a feature that many have been waiting for, placing agents in maintenance mode from the agent itself.
In this guide I will show you how quick and easy it is done.

Contents

Prerequisites

  • System Center Operations Manager 2016 or newer.
  • A computer with SCOM agent installed.

Verifying the agent on the monitored computer

First of all we will simply verify that the monitored computer has the SCOM agent installed, before proceeding.

  1. Let’s start by logging on the computer monitored by SCOM.
  2. Once we are logged on to the monitored computer, we will go to the control panel to verify the SCOM agent, go to Start and write “Control Panel” and then click on Control Panel.scom_agent_mm1.0
  3. The Control Panel should now have opened for us.scom_agent_mm1
  4. Once we are in the Control Panel, type “Monitoring” in the search field which can be found in the upper right corner, we should see the Microsoft Monitoring Agent in the search result, open it by clicking on it.scom_agent_mm2
  5. The Microsoft Monitoring Agent Properties window will open up and we will see our SCOM agent configuration.scom_agent_mm3
  6. If everything looks OK we will continue to the next step.

Importing the PowerShell module for maintenance mode

We will not go through how to import the SCOM maintenance mode PowerShell module.

In this guide, we will use my DPM server as a test subject.

scom_agent_mm168

  1. We will now open up a Windows Explorer and browse to the SCOM agent installation folder C:\Program Files\Microsoft Monitoring Agent\Agent\scom_agent_mm4
  2. The PowerShell module for the SCOM maintenance mode is called MaintenanceMode.dll, we will search for it in the SCOM agent installation folder by typing the exact name of the dll file.scom_agent_mm5.png
  3. The first search result should be the dll file we searched for, now that we made sure that it exists we can continue to import the module into PowerShell.
  4. Go to Start and search for “PowerShell”, right click on PowerShell and choose Run as administrator.scom_agent_mm141.png
  5. We should now have a PowerShell window open.scom_agent_mm15.png
  6. Now we will import the MaintenanceMode.dll PowerShell module by typing the following into our PowerShell window: Import-Module “C:\Program Files\Microsoft Monitoring Agent\Agent\MaintenanceMode.dll”scom_agent_mm80
  7. Hit Enter to import the module, once it’s done we should be able to start using the SCOM maintenance mode cmdlets.
  8. Once the importing of the module is successful we will use the Get-Help to see closer on the SCOM maintenance mode module commands, for this guide I will use the –ShowWindow switch to make it more clear.
  9. Type Get-Help Start-SCOMAgentMaintenanceMode -ShowWindow in our PowerShell window.scom_agent_mm11
  10. A Start-SCOMAgentMaintenanceMode Help window should appear on our screen.scom_agent_mm12.png
  11. The following list of reasons are acceptable by the cmdlet:
    PlannedOther
    UnplannedOther
    PlannedHardwareMaintenance
    UnplannedHardwareMaintenance
    PlannedHardwareInstallation
    UnplannedHardwareInstallation
    PlannedOperatingSystemReconfiguration
    UnplannedOperatingSystemReconfiguration
    PlannedApplicationMaintenance
    UnplannedApplicationMaintenance
    ApplicationInstallation
    ApplicationUnresponsive
    ApplicationUnstable
    SecurityIssue
    LossOfNetworkConnectivity
  12. In the help window we can see the syntax and all the parameters required to run the command to start maintenance mode on the monitored computer.

Setting the monitored computer in maintenance mode

The syntax that we will use to start a maintenance mode request is
Start-SCOMAgentMaintenanceMode.

Every SCOM agent has a Rule that runs a PowerShell script (ReadMaintenanceModeRegEntry.ps1) every 5 minutes to read the registry entries on the agent computers.

scom_agent_mm166
Note: The Agent Initiated Maintenance Mode Rule is disabled by default, you will have to create an override to enable it.

Once the SCOM management server has successfully read the registry entry, it will write an event to the Oparations Manager event log with the Event ID 2222 and it will put the agent computer in maintenance mode.

We will now perform a simple test to see what happens when we run the
Start-SCOMAgentMaintenanceMode PowerShell command.

In this test I will put the monitored computer in maintenance mode for a duration of 1 hour (60min).

  1. To start the maintenance mode request of an agent the only requirement needed is the duration of the maintenance mode period.
  2. Type the following command to start the maintenance mode request with a duration of 1 hour: Start-SCOMAgentMaintenanceMode -Duration 60 then hit Enter to run the command.scom_agent_mm131
  3. We will now be prompted if we want to continue with this operation.scom_agent_mm151
  4. Type Y for Yes and N for No, in our case we will go ahead and type Y.scom_agent_mm161
  5. Once the PowerShell command has run, it will write information to the Windows registry on the agent computer (HKLM:\Software\Microsoft\Microsoft Operations Manager\3.0\MaintenanceMode\Record)scom_agent_mm165.png
  6. If we try to run the Start-SCOMAgentMaintenanceMode again before the previous maintenance period is over we will get the following message:scom_agent_mm167
  7. Now that we have run the PowerShell command, we can confirm that the maintenance mode request is successful by opening the Event Viewer and look in the Applications and Services Log\Operations Manager event log for the event ID 2222.scom_agent_mm164.1

We have now successfully created a maintenance mode request.

Verifying the SCOM Management server that the agent went into maintenance mode

Lastly we will verify that our agent really went in maintenance mode for 1 hour (60min), we will check this on the SCOM management server.

  1. Logon to our SCOM management server.
  2. We will start by first checking the Operations Manager event log in the Event Viewer, for the Event ID 2223.
  3. Open the Event Viewer, expand the Applications and Services Log and select the Operations Manager event log.scom_agent_mm169scom_agent_mm163.1
  4. We can see that the SCOM management server has successfully put the agent computer, DPM.lab.ad in our case in maintenance mode.
  5. Next we will also check the Operations Manager console in the Monitoring view if the agent computer really is in maintenance mode.
  6. Open the Operations Manager scom console.
  7. We should automatically start in the Monitoring pane, on the list of monitoring items on the left side go to Windows Computers and find our agent computer where we initialized the maintenance mode.scom_agent_mm162
  8. We can now see that the DPM server is successfully in maintenance mode.

There we go, this is how easy it is to start maintenance mode from an agent computer.

638 total views, 8 views today

2 thoughts on “Enabling SCOM Maintenance Mode from a Monitored Computer”

  1. This only works interactively. How do you feed the “y” answer programmatically to run this in a non-interactive script?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.