Unregistering & Registering VMs

This post is about the way to unregister and register VMs from/to ESXi hosts using commands (Local TSM, SSH) not GUI (vSphere Client).

May be you ask, why should I do such a thing? well, assume you have two hosts in cluster without EVC enabled for it, in order to enable EVC for cluster, all VMs in that cluster should be powered off so the new setting would be apply to them as they coming up and if you have AD/DNS, SQL, vCenter as virtual, it means powering off these VMs as well

One way is to create secondary cluster with proper EVC config if you didn’t think about it before hand, then moving hosts to this new cluster one by one1.
Now it’s time to move most critical VMs (at least critical for making cluster working fine), for this action name of VMs, VMs ID and their storage path are needed.
For gathering these information “vim-cmd vmsvc/getallvms” command can be run, which showing all registered VMs on specific host.

As long as VM actions can be done by “vim-cmd vmsvc/” commands, Let’s check the available options:

Under “vim-cmd vmsvc/” there is “unregister” option; for checking it’s action and command parameters lets run this command once.

As the above picture shows, this command can be used for unregistering VMs and for this action VM IDs are needed.
From first step, I have write down two VM IDs for “SQL” and “vCenter”. (112, 48).

Let’s check the available (registered) VMs on this host and see if these two VMs are still in listed or not by using “vim-cmd vmsvc/getallvms

As the above picture shows, those two VMs are removed from first host (ESXi41-1 in my lab).
Now, list of all available VMs on the same storage which is accessible by second host (required for vMotion) is needed, for this action “ls /vmfs/volume/lun-001/” command can be use.

As long as all VMs registered with first host except “sql” and “vCenter (vc)”, I need to register them here.
After searching under “vim-cmd” commands for a while I find “registervm” command under “vim-cmd solo/“.

After running this command once and without any parameters, the result looks like this:

As the picture above shows, for registering VM to the host the full path of VM (ended with .vmx) is needed.
Also there is two other parameter which are optional, “Name” and “Resource Pool”.
“Name” would be shown up in the inventory and list of VMs and the “Resource Pool” would be the destination of specific VM, if no resource pool is selected the VMs would be place directly under the host.
So, I have tried to register these two VMs by running following commands:
vim-cmd solo/registervm /vmfs/volume/lun-001/sql/sql.vmx
vim-cmd solo/registervm /vmfs/volume/lun-001/vc/vc.vmx

After running each of these commands, System will assign new VM ID to each VM which can be used with other commands.

After registering these VMs, it’s time for checking if they will be listed as registered VMs or not by using “vim-cmd vmsvc/getallvms” command.

The last action in these series would be powering on these VMs by using “vim-cmd vmsvc/power.on VMID#” command, so the rest of configuration and then moving the other host to the cluster can be done.

But, there would be an extra step here.
As these VMs created and worked originally on other host and their UUID is registered there, so they will not power on until “system administrator” confirming the reason of new UUID.

After selecting the proper answer, the process will continue and the VM will be power on.

And the second VM needs the same process again.

1: For moving one host from cluster to the other, you must put that host in “Maintenance Mode” or shut it down.


Add a Comment
  1. Hi,
    I appreciate you work, Pls share if you have any document on command line on ESXi especially on VIM-cmd….

    1. Hope this helps a bit; unfortunately, I personally don’t have any document my self in this regard (except some posts I made) but you may find good info (in this regard) on “vm-help” site.
      I’d add a new section soon and try to write and describe each command there.

  2. Hey dude. what kind of wordpress theme are you using? i want it to use on my blog too.

  3. Good link buddy i too appriciate your work
    …..it would be great help if you can provide ESX.4.0 and 5 installation and troubleshooting docs. or links.

It's your kindness to leave a reply/feedback