Orphaned VM’s can be caused by a number of things such as database, storage or network connectivity issues to vCenter server during a vmotion. I have listed a few methods to resolve the orphaned VM error below.
Method 1 – Restarting VPXA service
Initially this can sometimes be resolved by simply restarting the vpxa service on each esxi host. The service is the agent which services the connectivity between the esxi host and the vCenter Server for management. This will not cause a HA failover but a brief disconnect of the host from vCenter while the service is restarted. This can be completed as below.
Select the relevant host in the vclient
Select the Configuration tab
Select Security Profile under Software
On the right-hand side of the page select Properties
Select the vpxa service and click on Options
Click on Restart
If this hasn’t resolved the orphaned VM issue then move on to Method 2.
Method 2 – Kill the world
Open SQL Management studio and create a connection to the vCenter database, run the below query to find the last host in which the VM was or is running on.
SELECT vpxv_vms.vmid, vpxv_vms.NAME, vpxv_vms.hostid, vpxv_hosts.NAME FROM vpxv_vms JOIN vpxv_hosts on VPXV_VMS.HOSTID = VPXV_HOSTS.HOSTID WHERE ( (vpxv_hosts.hostid = vpxv_vms.hostid) AND (vpxv_vms.NAME = 'virtual_machine_name') )
Start the Esxi Shell and SSH services
Select the relevant host in the vclient
Select the Configuration tab
Select Security Profile under Software
On the right-hand side of the page select Properties
Select the Esxi Shell and SSH services and click on Options
Click on Start
Using a SSH client connect to the Esxi Host, login and type esxcli vm process list and copy the world ID for the relevant VM.
Type esxcli vm process kill -t soft -w <WORLD ID> to kill the process of the VM, if you know which datastores the VM exists on then right-click the VM and select remove from inventory DO NOT SELECT DELETE FROM DISK!.
Browse to the datastore in which the VM files exist and right-click on the relevant .vmx file and select Add to Inventory.