In this article, we'll show you how to deal with VMs which are reported to have an Invalid Status as shown in the screenshot below. This is a common problem many VMware and System Administrators are faced with when dealing with VMs. We'll show you how to enable SSH on ESXi (required for this task), use the vim-cmd to obtain a list of the invalid VMs, use the vim-cmd /vmsvc/unregister command to unregister - delete the VMs and edit the /etc/vmware/hostd/vmInventory.xml file to remove the section(s) that references the invalid VM(s).
The Invalid Status issue is usually caused after attempting to delete a VM, manually removing VM files after a vMotion, a problem with the VMFS storage or even after physically removing the storage from the ESXi host e.g replacing a failed hdd.
Another difficulty with VMs stuck in an Invalid Status is that VMware will not allow you to remove or delete any Datastore associated with the VM e.g if you wanted to remove a HDD. For safety reasons, you must first remove or migrate the affected VM so that there is no VM associated with the Datastore before VMware allows you to delete it.
Concerned about your VM machines and their data? Download now your Free Enterprise-grade VM Backup solution
The screenshot below shows ESXi failing to delete datastore 256G-SSD - which is used by VM FCX-ISE1 above, now reported to be in an Invalid Status:
As most System Administrators discover in these situations - they are pretty much stuck and the only way to remove the VM, now marked as 'Invalid', is to delete it as the Unregister option cannot be selected when right clicking on top of the VM:
Notice in the screenshot above how the Unregister or Delete menu options are not available.
The only method to delete this VM is to use the SSH console on the ESXi host and execute a number of commands. This implies that SSH has been enabled on the ESXi host.
Read our quick guide on “How to enable SSH on an ESXi host” if SSH is not enabled on your ESXi host.
Once ssh is enabled, connect to your ESXi host with any ssh client such as e.g Putty using your ESXi root credentials, then use the vim-cmd with the following parameters to obtain a list of the invalid VMs:
[root@esxi1:~] vim-cmd vmsvc/getallvms | grep invalid
Skipping invalid VM '8'
From the command output it is apparent that VM No.8 is the one we are after. As a last attempt we can try to reload the VM in hope it will rectify the problem by executing the vim-cmd vmsvc/reload command:
faultCause = (vmodl.MethodFault) null,
faultMessage = <unset>,
reason = "Invalid fault"
msg = "Received SOAP response fault from [<cs p:03d09848, TCP:localhost:80>]: reload
Unfortunately, no joy. We now need to proceed to unregister/delete the VM using the vim-cmd /vmsvc/unregister command as shown below:
[root@esxi1:~] vim-cmd /vmsvc/unregister 8
Once the command is executed, the invalid VM will magically disappear from the ESXi GUI interface:
Another way to delete the VM is to edit the /etc/vmware/hostd/vmInventory.xml file and remove the section that references the invalid VM. In the snippet below we need to simply remove the highlighted text:
When finished, simply save the vmInventory.xml file.
This article showed how to deal with an ESXi VM that is in an invalid status. We explained possible causes of this issue, how to enable SSH on ESXi and the SSH commands required to reload or delete the invalid VM. Finally we saw how to delete a VM by executing the vim-cmd /vmsvc/unregister command or editing the vmInventory.xml XML file.