ESXi 6.5 – remove an invalid virtual machine using the command line
I have a standalone ESXi 6.5 host that is showing some invalid VMs:
This is because I removed the storage containing the VMs without removing them from the inventory. Unfortunately, I cannot remove them from the GUI as most of the options in the context-menu are greyed out – the only way is via the command line:
- Connect to the host using SSH (I prefer to use PuTTY)
- Log in
- Run the following command:
vim-cmd /vmsvc/getallvms
- Now run the following command, replacing the <id> with the ID of the invalid VM to remove:
vim-cmd /vmsvc/unregister 10