You can list, unregister, and register virtual machines by using vmware-cmd.

Registering or unregistering a virtual machine means adding the virtual machine to the vCenter Server or ESXi inventory or removing the virtual machine.


If you register a virtual machine with a vCenter Server system, and then remove it from the ESXi host, an orphaned virtual machine results. Call vmware-cmd -s unregister with the vCenter Server system as the target to resolve the issue.

The following example scenario lists all registered virtual machines on a vCenter Server, unregisters a virtual machine, and reregisters the virtual machine.


Run vmware-cmd -l to list all registered virtual machines on a server.

vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -l

The command lists the VMX file for each virtual machine.


Run vmware-cmd -s unregister to remove a virtual machine from the inventory.

vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -s unregister /vmfs/volumes/Storage2/testvm/testvm.vmx

The system returns 0 to indicate success, 1 to indicate failure.


When you run against a vCenter Server system, you must specify the data center and the resource pool to register the virtual machine in. The default data center is ha-datacenter and the default resource pool is Resources.

When you run against an ESXi host, you usually do not specify the resource pool and data center. However, if two virtual machines with the same name exist in two resource pools, you must specify the resource pool.


Run vmware-cmd -l again to verify that the virtual machine was removed from the inventory.


Run vmware-cmd -s register to add the virtual machine back to the inventory.

vmware-cmd -H <vc_server> -U <login_user -P <login_password --vihost <esx_host> -s register /vmfs/volumes/Storage2/testvm/testvm.vmx

The system returns 0 to indicate success, 1 to indicate failure.