I have written an automated tool to deploy vCenter onto an ESXi host server - which works. I am now trying to add functionality to uninstall vCenter from a host, I guess the removal of the vCenter appliance can be achieved by just removing the vCenter instance from the host server - something like:
remove-vm -vm $vcenter_ref -deletepermenantly -confirm:$false
What I am not so sure about is how to handle the removal (or disassociation) of hosts managed by vCenter - if I remove the vCenter appliance the hosts which it used to manage will still think they are associated with the host.
For example, if I had an vCenter instance named Vcsa with host "MyHost1" associated with it - if I delete the vCenter appliance and access the summary page of "MyHost1" in vSphere the host still has a "Disassociate host" option available (indicating that it still thinks it is associated with the non-existing host). I suppose the solution then would be to iterate over each managed host in PowerCLI and disassociate it which is fine - except I cannot guarantee that all of the managed hosts will be available/online to perform this action. Potentially there could be hundreds of servers in the environment so manually powering these on is not an option - but I dont want this to hinder the vCenter uninstall?
Anyone done something like this before or got an idea how this might be done?