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:

  1. Connect to the host using SSH (I prefer to use PuTTY)
  2. Log in
  3. Run the following command:
    vim-cmd /vmsvc/getallvms


  4. Now run the following command, replacing the <id> with the ID of the invalid VM to remove:
    vim-cmd /vmsvc/unregister 10
[BlogBookmark] [Blogsvine] [] [Digg] [Facebook] [Furl] [Google] [LinkedIn] [MySpace] [Reddit] [Slashdot] [StumbleUpon] [Twitter] [Windows Live] [Yahoo!] [Email]