Command Shell Examples
Useful SQL Queries
Agents: remove configured management group or uninstall agent using command line - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

Agents: remove configured management group or uninstall agent using command line

Agents: remove configured management group or uninstall agent using command line

  • Comments 5
  • Likes

I had a question today about uninstalling an agent using the command line.  The options referenced here are great for installing, configuring and modifying an agent and all possible options.  Here are some additional notes that may come in handy, which supplements Rob’s excellent command line post.

Beware of word wrap on these commands.  They are all one-liners.

 

Remove a specific MG configuration from the agent

MsiExec.exe /i \\path\MOMAgent.msi  /norestart /qn /l*v %temp%\RemoveMG.log MANAGEMENT_GROUP=<OldManagementGroup> MANAGEMENT_GROUP_OPERATION=RemoveConfigGroup REINSTALL=ALL

Remove all configured MG's

You'll need to run this as many times as there are MG's.  Only one MG at a time can be removed using this method.  I’m not 100% certain, but I believe the program simply selects the first MG found in the registry.

MsiExec.exe /i \\path\MOMAgent.msi /norestart /qn /l*v %temp%\RemoveMG.log MANAGEMENT_GROUP_OPERATION=RemoveConfigGroup

If AD Integration is enabled on the agent, the Health Service will remain running.  If AD Integration configuration is discovered in the future, this agent will pick up that configuration and start reporting to specified MG.

If AD Integration is not enabled on the agent, the Health Service will stop but the agent will remain installed.  The Health Service will continue to start automatically during server startup, but will again be stopped once it discovers AD Integration is disabled and there are no MG’s configured.

Uninstall R2 Agent

Removes Agent binaries and all configured MG’s

msiexec /x {25097770-2B1F-49F6-AB9D-1C708B96262A} /qn /norestart /l*vx %temp%\RemoveAgent.log

Uninstall SP1 Agent (slipstream only, not RTM upgrade)

Removes Agent binaries and all configured MG’s

msiexec /x {E7600A9C-6782-4221-984E-AB89C780DC2D} /qn /norestart /l*vx %temp%\RemoveAgent.log

Uninstall SP1 Agent (RTM > SP1 upgrade)

I have seen other references to this GUID for SP1 agents as well.  This might be the one for RTM > SP1 upgraded agents, but I haven’t tested this one.

msiexec /x {768DB8BD-CB3A-43F4-9A4C-BA2921D27AD3} /qn /norestart /l*vx %temp%\RemoveAgent.log

I’ve heard of some issues while using the optional logging parameters.  If you're having problems with the above commands, try without the logging options.

For example:

msiexec /x {25097770-2B1F-49F6-AB9D-1C708B96262A} /qn /norestart

Finally, if you have trouble with any of these GUID’s, Mark Wolzak posted a nice article about how to find the correct GUID here.

I do not moderate this blog anymore. If you have a question regarding this post, send me a message.

Comments
  • Thanks for the article. Worked like a charm for me since the cleanup tool does not work on Windows Server 2008 or later, for now that is :)

  • Thanks heaps this worked for me on a Windows 2008 R2 env.

  • Hi johnathan, i have a query if we need to unistall the one zone in case agent is dual homed,what should we do?

    MsiExec.exe /i \\path\MOMAgent.msi  /norestart /qn /l*v %temp%\RemoveMG.log MANAGEMENT_GROUP=<OldManagementGroup> MANAGEMENT_GROUP_OPERATION=RemoveConfigGroup REINSTALL=ALL

    i dont find this momagent.msi in the agent-managed agents \\path\MOMAgent.msi.so in this case what should we do?can you help me out in this?

  • Hi Vivek,

    The MSI package is required using this method.  This is the agent installation package.  \\path is the location of the MSI.  It can be locally or on a remote file system.  This package is always located on the Management Server and RMS, so you could put in \\MS_Computer_Name\path_to_AgentManagement_directory\MOMAgent.msi.

    MS_Computer_Name is the computer name of your management server.

    path_to_AgentManagement_directory is the file system path (on the MS) to the Agent Management directory.  This is located in the SCOM program files.

  • Hi Jonathan,

    I like this article.

    A new challenge is when you have to migrate a big scom environment when using the side-by-side migration. In this process all the agent are multi-homed when upgrading them from the management console. When you have a big environment with let's say over 1000 agents there must be another way to do this in a script. i have been browsing the internet for a couple days now and cannot find anything that will help me with this.

    I hoped you have something in place for this problem which i will probably encounter many more times in the future.

    Thanks,

    Marthijn.