Scenario:

– A running OpsMgr 2007 environment with agents – to be degraded.

– New OpsMgr 2012 environment without agents. You start pushing agents from OpsMgr 2012, to the same servers which are monitored in OpsMgr 2007.

– You successfully install the agent on all servers, which means the agents now report to both OpsMgr 2007 and 2012. You then uninstall all the agents from OpsMgr 2007.

This works fine, but the problem is that the management group information for the 2007 environment doesn’t disappear:

image

I digged into the registry, where i could see that these keys are not deleted:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\HQ2007

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HealthService\Parameters\Management Groups\HQ2007

Deleting these registry keys will delete the entry in Control Panel. Great – but lets say you have 200 servers – do you really want to do this manually? None of my costumers wants to!

 

As a solution, a good colleague of mine, Claus Codam has created a really cool Powershell script. Download it from here.

 

The use os the script is quite simple:

 

You can either specify a LDAP query to retrieve servers from Active Directory, or specify a text document containing the server names. You simply need to change the stuff marked with red.

 

### Domain Name, which will be appended to Machine Names, that is not a FQDN.
$Domain =    "HQ.com"

### LDAP Path to retrieve Machine Names from. Set to "" if not used.
$LDAP =        "LDAP://OU=Clients,OU=HQ,DC=HQ,DC=com"

### File Path to read Machine Names from (one per line). Set to "" if not used.
$File =        "C:\Servers.txt"

### List of all the Registry KeyTrees that should be deleted.
$arrRegKeyT = @("SOFTWARE\\Microsoft\\Microsoft Operations Manager\\3.0\\Agent Management Groups\\HQ2007",
        "SYSTEM\\CurrentControlSet\\services\\HealthService\\Parameters\\Management Groups\\HQ2007")

Running the script:

image

Note: run this scripts from a x64 machine.

After running the script all information about the old MGM has been deleted:

image