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.

Posted on June 21, 2021 at 23:39 by simon · Permalink
In: Tech, Vmware

2 Responses

Subscribe to comments via RSS

  1. Written by Claire Stokes
    on 3 September 2021 at 22:54
    Reply · Permalink

    perfect! thanks

  2. Written by KW
    on 27 January 2023 at 10:33
    Reply · Permalink

    Thanks for the tip! Command Syntax was not clear on Docs 😉

Subscribe to comments via RSS

Leave a Reply