Friday 13 July 2007

Some Ops manager Agent Stuff

We had some problems every time we built a new management group in our lab. All the old agents would still be trying to report to the old management group. This was a pain because all this did was clutter up the Operations Manager Log. The solution we used was to create a task that would completely uninstall all the agents. They would then be automatically reinstalled by the active management group if you have applied the overrides to enable the recoveries as detailed in the System Center Management Pack Guide. A bit of powershell would then run this task against all agents.

To Create the Uninstall Task

On the Authoring pane on the console create a new command line agent task called CompleteUninstall. The target is Windows Computer. The command line settings are shown below.





Uninstall command for Agent (RTM)

MsiExec.exe /x {E7600A9C-6782-4221-984E-AB89C780DC2D} /quiet

This gives us a task that ca be run on an agent to perform an uninstall of an agent. To run this on all agents the easiest way is to do it in a powershell script

Powershell Script to run the task for all agents

$uninstallTask = get-task | where {$_.Name -eq "CompleteUninstall"}
foreach($agent in get-agent)
{
$server = $agent.Displayname
$server
start-task -asynchronous -task:$uninstallTask -path .\Microsoft.SystemCenter.AgentManagedComputerGroup\$server
}


Save this script as a .ps1 file and then run it from the Operations Manager Command Shell. The results of these tasks will always show in the Operations Console under Task Status as failed as the Agent has been removed.

No comments: