Today while I was setting up a new vCloud lab at home I just noticed that by mistake I added one of the ESXi to the wrong cluster and in the wrong datacenter.
To be honest, fixing this is not a big deal. Just put the host in maintenance mode, get it out of the cluster and move to the correct datacenter. With the vSphere Client it can be done with a couple of clicks and a simple drag and drop. But my mistake gave me the opportunity to correct it using PowerCLI and write this small but hopefully useful blog post.
To explain a bit the scenario. I currently have two datacenters in my homelab, one for my day to day tests and labs and another one for vCloud Director.
Step 1 - Put the host in maintenance mode
To do so we re going to use the Set-VMHost cmdlet.
Step 2 - Move the host out of the cluster
To perform this use the Move-VMHost cmdlet.
If you check now the vSphere Client will see the host out of the cluster but still in the same datacenter.
Step 3 - Move the host to the correct datacenter
Now that our host is in maintenance mode and out of the cluster it is time to move it to the correct datacenter. Again we will use Move-VMHost.
Finally put the ESXi out of maintenance mode.
Check that everything is OK with the vSphere Client and we are done.