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: