6.5

Table Of Contents
List and Register Virtual Machines
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.
I 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.
Procedure
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 le 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.
N 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.
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.
Retrieving Virtual Machine Attributes
vmware-cmd includes options for retrieving information about a virtual machine.
Each option requires that you specify the virtual machine path. See “Format for Specifying Virtual
Machines,” on page 124. You must also specify connection options, which dier from other vCLI commands.
See “Connection Options for vmware-cmd,” on page 124.
Chapter 8 Managing Virtual Machines
VMware, Inc. 125