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

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.