OpsManager: Disable SCOM agent task

One of the regulary MOB tasks in SCOM is to remove agents from monitoring.

If the security setting in the Global Management Server Settings is set to “Review new manual agent installations in pending management view” and you have not set the checkmark before “Automatically approve new manually installed agents” then you will see deleted agents popping up again in the pending management view until the server is decomissioned or the service is stopped. Also you will see 20000 events in the OpsManager event log on the management servers.
In a bigger environment this can be too much unnecessary noise.

The easiest way to avoid that is to stop and disable the System Center Management service on the agent prior to deleting it out of the console. An agent based task can help doing that through the console. This task can be created directly in the console in a SCOM 2007 R2 or a SCOM 2012 environment and you can also use an unsealed management pack for it.

The sc.exe must be available on the server, where you run the task. Normally it is located in %windir%\system32.

Here are the steps to create the task: 

Open the OpsManager console and go to Authoring: Management Pack Objects: Tasks.

Click on “Create a New Task”.


Select Agent Task: Run a script.

Select an existing management pack or create a new one.

Click Next.


Give it a name and a description. Example: Disable SCOM agent.

Select a target. I recommend to use Agent, then it does not pop up in the Windows Computers view but in the views below Operations Manager.

Click Next.


Enter a name for the script. Example: disablescom.vbs.

You can leave the default timeout (1 min), because it normally should only run some seconds.

Enter the following lines in the script area:

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WshShell.Run “%windir%\system32\sc.exe config healthservice start= disabled” 
WshShell.Run “%windir%\system32\sc.exe stop healthservice”

Click Create.

Now the task gets created and you should find the new task if you go to the monitoring area and select a server in a state view below the Operations Manager: Agent Details folder.


After running the task on an agent the service is stopped and disabled. Now you can go on and delete the agent out of the console.


Published by


* 1974, female, working as a IT Senior System Analyst in a chemical company. Main topics: System Center Operations Manager 2012, System Center Orchestrator 2012, System Center Configuration Manager 2012. Monitoring servers since 2002, started with NetIQ Appmanager. Twitter: @NatasciaHeil

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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