Uninstall vCenter appliance and disassociate any hosts regardless of their state.

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

Open in new window

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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
vCenter Server is just a management server, so nothing will affect the hosted VMs, on the hosts.

Yes, you will have to manually disassociate the hosts.

What is your goal ?

add hosts to another vCenter server ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.