Remove orphaned VM

If you need to remove an orphaned VM from ESXi host (and vCenter) use the below commands on ESXi command line (connect via SSH):

vim-cmd vmsvc/getallvms | grep -i invalid

Skipping invalid VM '1234'

vim-cmd vmsvc/get.summary 1234 |grep -i path

vmPathName = "[] /vmfs/volumes/vm_folder/vm_name/vm_name.vmx",

vim-cmd vmsvc/unregister 3955
vim-cmd vmsvc/getallvms | grep -i invalid


Note: If the VM is removed from ESXi host, but not vCenter then you will need to restart your choice of ESXI host.d service or vCenter services (reboot)