I was recently at a customer where we installed Operations Manager and while installing we did notice some strange behaviors in some of the agents. As it turned out there was and old OpsMgr installation with the same management group name as the one we had chosen.
This meant that the agents always reverted back to the old server. To remove this behavior all references in AD where removed and the new server published new AD integration information. This is however not enough as you also need to clear the agent health cache and remove the old Management Group information from the registry.
To make this easier I wrote a script that using remote Power Shell connects to the computer/computers, stops the health service, clears the health cache, removes the registry entries and then starts the health service again.
The script can be downloaded here and is pretty straight forward. To run the script just enter a computername of the server where the agent is installed and the health cache will be reset. When used with the -ClearGroups switch it will also remove any references in the registry to all management groups.
For mor information on the script use get-help clear-healthcache.ps1
Please leave a comment if you find something that is not working or if you just like and use the script.