Trying to delete the VM fails with Error- "Invalid virtual machine state"
Hard disk on the VM reflects "0" MB
Environment
ESXi 7.x
ESXi 8.x
Cause
This is observed when the vmdk is manually deleted from the datastore
Resolution
Disclaimer: Ensure that the VM's directory does not contain any flat.vmdk, vmdk or delta disk files. Verify this with the customer and follow the steps outlined below:
Note: These Steps are to be followed only if the VMDK was deleted from Datastore and the VM is no longer required.
Navigated to Edit Setting of the VM
Remove the Attached Hard Disk reflecting "0" MB and click Save
The Re-configuration Task Might fail with Error- vmdk not found "Cause- VMDK was deleted from the datastore"
Recheck the disk in edit setting and it should no longer reflect (This is a Stale Entry in vmx file)
Right-click the virtual machine in the Inventory and select Delete VM.
Click Yes to delete the virtual machine.
The VM should be deleted successfully.
Additional Information
Note: If VM has multiple Disks in place and if we need to delete or remove single VMDK, the operation should be carried out from the vCenter or Host VM UI Edit Setting and not the Datastore Level.