Automated process to remove the OpsMgr 2007 from a multi-homed 2007/2012
In multi-homed migrations for Operations Manager one of the last steps is to remove the Operations Manager 2007 monitoring from the system. The migration process is discussed here but that does not provide details on how to actually perform the agent removal. Our initial tests did not work to perform an uninstallation of the agent from the Operations Manager 2007 environment once the agent had been upgraded to Operations Manager 2012 (at least it would not remove from the original management group it was a member of). There are a couple of approaches which I have seen which will work. The first is through a vbscript, the second through a batch script. Either of these could be pushed out through a Configuration Manager package to automate the removal of the original management group.
Here’s the clean way to do this:
You can do this through the SDK – discussed on page 304 of the Operations Manager Unleashed book. Specifically it states that you can do this through a VBscript shown below:
Set objMSCOnfig = CreateObject ("AgentConfigManager.Mgmt.SvcCfg")
Call objMSConfig.RemoveManagementGroup ("GROUP1")
Here’s the unclean way:
If you run into a situation where you need to stop the agent from reporting to the original 2007 management group but leave it reporting to the 2012 management group this is a second way that I have used which may not be supported but worked for me.
- Stop the service [Microsoft Monitoring Agent, Service name = HealthService] net stop HealthService
- Remove the registry key [HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\[OldMGName] reg delete [key]
- Remove the registry key [HKLM\SYSTEM\CurrentControlSet\Services\HealthService\Parameters\Management Groups\[OldMGName] reg delete [key]
- Restart the service [Microsoft Monitoring Agent, Service name = HealthService] net start HealthService
The script is as follows where <MANAGEMENTGROUPNAME> is your management group name.
net stop HealthService
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\<MANAGEMENTGROUPNAME>" /f /va
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HealthService\Parameters\Management Groups\<MANAGEMENTGROUPNAME>" /f /va
net start HealthService
You can also remove a Management group from a SCOM 2012 agent with script (by Bob’s Cornelissen) which is available at: http://gallery.technet.microsoft.com/Remove-a-Management-group-336c849a/view/Discussions