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.

Prerequisite
The sc.exe must be available on the server, where you run the task. Normally it is located in %windir%\system32.
http://support.microsoft.com/kb/251192

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”.

disablescomtask1

Select Agent Task: Run a script.

Select an existing management pack or create a new one.

Click Next.

disablescomtask2

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.

disablescomtask3

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.

OpsManagerview

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.

Advertisements
Post a comment or leave a trackback: Trackback URL.

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

%d bloggers like this: