I have lately had few orphaned VMs in my Home Lab vCenter, as I was recreating my setup. Some of the Virtual machines were deleted directly from ESXi host, but still had records in the vCenter inventory. Below how orphaned VMs looked in my vCenter.
I have looked online for a way to remove these orphaned VMs, and while one of the KB article suggested to add it to a folder then remove the folder, that did not work as that KB was only for older versions of vSphere.
One method to do this, is to use one of the below command lines methods where any of them will do the trick:
PowerCLI
Remove-VM vm_name -deletepermanently
vMA
vmware-cmd --server esxhost –s unregister path_to_vmx_file
vmware-cmd --server vcenter --vihost esxhost –s unregister path_to_vmx_file vifs --server esxhost --rm “[datastore] path_to_vmx_on_datastore”
CLI
vim-cmd vmsvc/destroy vmid
For those lazy ones, that don’t want to fire up a command line utility and then construct a command line to do the trick, I have a good news for you. You can delete that orphan VM in the GUI by right clicking the VM, then choosing All Virtual Infrastructure Actions ==> More UnCategorized Actions ==> Remove from Inventory. The screenshot below demonstrate that. Many miss this, as it is three menu deep.
One response to “How to remove orphaned VM from vCenter the easy way”
Thank you for making this so simple and easy to follow, even for us lazy people who are not comfortable in the CLI