6.0

Table Of Contents
VMware, Inc. 107
Chapter 8 Managing Virtual Machines
To list, unregister, and register virtual machines
1Runvmware-cmd -ltolistallregisteredvirtualmachinesonaserver.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -l
ThecommandliststheVMXfileforeachvirtualmachine.
/vmfs/volumes/<storage>/winxpPro-sp2/winxpPro-sp2.vmx
/vmfs/volumes/<storage>/RHEL-lsi/RHEL-lsi.vmx
/vmfs/volumes/<storage>/VIMA0809/VIMA0809.vmx
.....
2Runvmware-cmd -s unregistertoremoveavirtualmachinefromtheinventory.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host>
-s unregister /vmfs/volumes/Storage2/testvm/testvm.vmx
Thesystemreturns0toindicatesuccess,1toindicatefailure.
3Runvmware-cmd -lagaintoverifythatthevirtualmachinewasremovedfromtheinventory.
4Runvmware-cmd -s registertoaddthevirtualmachinebacktotheinventory.
vmware-cmd -H <vc_server> -U <login_user -P <login_password --vihost <esx_host> -s register
/vmfs/volumes/Storage2/testvm/testvm.vmx
Thesystemreturns0toindicatesuccess,1toindicatefailure.
Retrieving Virtual Machine Attributes
vmware-cmdincludesoptionsforretrievinginformationaboutavirtualmachine.Eachoptionrequiresthat
youspecifythevirtualmachinepath(see“FormatforSpecifyingVirtualMachines”onpage 106).Youmust
alsospecifyconnectionoptions,whichdifferfromothervCLIcommands(see“ConnectionOptionsfor
vmwarecmd”onpage 106).
Youcanuse
vmware-cmdoptionstoretrieveanumberofdifferentvirtualmachineattributes.Foracomplete
listofoptions,seethevSphereCLIReference.
Theguestinfooptionallowsyoutoretrieveinformationabouttheguestoperatingsystem.Forexample,
youcanretrievethenumberofremoteconsolesallowedbyavirtualmachinebyusingguestinforwith
theRemoteDisplay.maxConnectionsvariable.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getguestinfo RemoteDisplay.maxConnections
TheHardeningGuideincludesadditionalinformationaboutvariablesyoucanuseinconjunctionwith
guestinfo.Acompletelistisnotavailable.
Thegetuptimeoptionretrievestheuptimeoftheguestoperatingsystemonthevirtualmachine,in
seconds.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getuptime
getuptime() = 17921
Thegetproductinfo productoptionliststheVMwareproductthatthevirtualmachinerunson.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getproductinfo product
NOTEWhenyourunagainstavCenterServersystem,youmustspecifythedatacenterandtheresource
pooltoregisterthevirtualmachinein.Thedefaultdatacenterisha-datacenterandthedefaultresource
poolisResources.
WhenyourunagainstanESXihost,youusuallydonotspecifythe
resourcepoolanddatacenter.
However,iftwovirtualmachineswiththesamenameexistintworesourcepools,youmustspecifythe
resourcepool.