6.0

Table Of Contents
VMware, Inc. 31
Chapter 4 Running vCLI Host Management Commands
OnWindows,youcansetenvironmentvariablesintheEnvironmentpropertiesdialogboxoftheSystem
controlpanel.Forthecurrentsession,youcansetenvironmentvariablesatthecommandlinebyusinga
commandlikethefollowing:
set VI_SERVER=<your_server_name_or_address>
See“UsingvCLICommandsinScripts”onpage 36foranenvironmentvariableexample.
Using a Configuration File
Youcanuseatextfilethatcontainsvariablenamesandsettingsasaconfigurationfile.Variablescorresponding
totheoptionsareshowninTable 42,“vCLIConnectionOptions,”onpage 34.
PassintheconfigurationfilewhenyourunvCLIcommands,asfollows:
<command> --config <my_saved_config> <option>
Forexample:
esxcli --config <my_saved_config> network ip interface list
vicfg-mpath --config <my_saved_config> --list
IfyouhavemultiplevCenterServerorESXisystemsandyouadministereachsystemindividually,youcan
createmultipleconfigurationfileswithdifferentnames.Torunacommandorasetofcommandsonaserver,
youpassinthe
--configoptionwiththeappropriatefilenameatthecommandline.
Thefollowingexampleillustratesthecontentsofaconfigurationfile:
VI_PSC = XX.XXX.XXX.XX
VI_USERNAME = administrator@vsphere.local
VI_PASSWORD = admin_password
VI_PROTOCOL = https
VI_SERVER = my_vc
Ifyouhavesetupyoursystemtorunthisfile,youcanrunscriptsagainstthespecifiedESXihostafterwards.
Using Command-Line Options
Youcanpassincommandlineoptionsusingoptionnameandoptionvaluepairsinmostcases.ForESXCLI
commands,youcanuselongorshortoptions.Anequalsignbetweenoptionnameandoptionvalueis
optional.
esxcli --server <vc_HOSTNAME_OR_IP> --username <privileged_user> --password <pw> --vihost
<esxi_HOSTNAME_OR_IP> <namespace> [<namespace]...> <command>
--<option_name=option_value>
ForothervCLIcommands,uselongorshortoptions.Anequalsignisnotsupported.
<vicfg- command> --server <vc_HOSTNAME_OR_IP> --username <privileged_user> --password <pw>
--vihost <esxi_HOSTNAME_OR_IP> --<option_name option_value>
Someoptions,suchas--help,havenovalue.
Thefollowingexamplesconnecttotheserverasusersnow-whitewithpassworddwarf$.
I
MPORTANTDonotuseescapecharactersinenvironmentvariables.
CAUTIONLimitreadaccesstoaconfigurationfilethatcontainsusercredentials.
IMPORTANTEnclosepasswordsandothertextwithspecialcharactersinquotationmarks.
WhenrunningcommandsonWindows,usedoublequotes(“ “).WhenrunningcommandsonLinux,use
singlequotes(‘ ‘)orabackslash(\)asanescapecharacter.