Listing and Registering Virtual Machines
Registering or unregistering a virtual machine means adding the virtual machine to the vCenter Server or ESXi inventory or removing the virtual machine.
Important 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.
To list, unregister, and register virtual machines
1
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.
/vmfs/volumes/<storage>/winxpPro-sp2/winxpPro-sp2.vmx
/vmfs/volumes/<storage>/RHEL-lsi/RHEL-lsi.vmx
/vmfs/volumes/<storage>/VIMA0809/VIMA0809.vmx
.....
2
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.
3
Run vmware-cmd -l again to verify that the virtual machine was removed from the inventory.
4
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.