Remove duplicate virtual machines in vCenter - ESXi

I recently landed into a situation where I had storage vmotion'ed one of my vm's on a different data store and after it finished, I noticed that in vcentre there was another instance of the same name created! (oh crap!)

Thankfully the .vmdk file was only on the new DS and also the .vmx file for that vm however on the old DS i could see some log files and also a .vmx file. Now the catch was finding out if this .vmx file had anything to do with the moved vm in the new data store (I didnt think so as the moved Vm already had its own vmx)

I could not

  • Shutdown the ghost vm
  • Move the ghost vm
  • Reset the ghost vm

All the above made sense as it did not have its vmdk file but since I could not shut it down I was not able to remove it from inventory. So in order to fix the issue safely, I first tried to perform a new storage vmotion of the working  vm to a different datastore and it worked but still could not delete or shutdown the ghost vm. So as a last resort I logged into  the ESXi host which the ghost vm said it was on in vCentre and restarted the management services and after that the ghost vm showed up as orphaned and in a shutdown state!.

To restart the management services, login to the host using SSH and run the below command:

services.sh restart ( Please note that this will not affect your working virtual machines and its completely safe, you might see the host getting disconnected from vcentre for a bit but it will come back, so don't worry)

So I was able to delete the vm safely now and life was back to normal!

-Alstar