How to unregister an ESXi VM using the CLI
Occasionally a VM shows as being in ‘invalid’ state, this can be because the files aren’t available, are corrupted, after a network outage etc.. All options are greyed out so it is not possible to do anything with it through the web console so we have to use the CLI to unregister it. We can then register it again or remove the broken files etc.
Login using SSH or use the local console
Type the following to find the VM number of the invalid VM:
vim-cmd vmsvc/getallvms | grep invalid
The output will be something like the following, showing the VM number:
Skipping invalid VM '8'
We can try to reload it but it’s unlikley to work:
vim-cmd vmsvc/reload 8
If it failed we just have to unregister it so we can either register it again or just remove it from the web console:
vim-cmd vmsvc/unregister 8
That’s it, the VM should have disappeared from the web console.
on 3 September 2021 at 22:54
· Permalink
perfect! thanks
on 27 January 2023 at 10:33
· Permalink
Thanks for the tip! Command Syntax was not clear on Docs 😉