Issue
After storage failure, virtual machines are lost and show as invalid in ESXi management console. The delete option in the GUI interface is greyed out so they should be removed manually.
Environment
Hypervisor ESXi 5.0 and above.
Resolution
- Enable SSH access by starting TSM-SSH service from GUI interface as shown below :
- open an SSH connection using putty session to the designated hypervisor host.
- run the following command to get a list of available VMs:
- vim-cmd vmsvc/getallvms
- If you see the VM listed, note the VMID and use it in the following command to unregister that VM.
- vim-cmd /vmsvc/unregister <VMID>
- If the VM is not listed, proceed by editing the following file using vi tool and delete the lines between and including the following XML elements: <ConfigEntry id="VMID"> and the next <ConfigEntry> as shown in the screenshot below where VMID=0 as an example:
- vi /etc/vmware/hostd/vmInventory.xml
- Notes :
- You can make a backup copy of this file before editing it by running : cp /etc/vmware/hostd/vmInventory.xml /etc/vmware/hostd/vmInventory.xml.old
- While using the vi editor you can :
- type "dd" to delete a line
- Press Esc to enter command mode then type :wq to save and quit the file
- You can use cat /etc/vmware/hostd/vmInventory.xml to verify that the file was edited correctly
- Disable SSH access by stopping TSM-SSH service from GUI interface
- After modifying the vmInventory.xml file, you need to reboot the hypervisor.