I found a specific command-line interface (CLI) in the vSphere documentation to execute a command I needed. Do I have to use that CLI when there are others I use more regularly?
VMware provides a number of command-line interface options for its customers to connect and manage a vSphere environment. There's the vSphere CLI (vCLI), PowerCLI, and also local commands inside the ESXi Shell. Despite these options, choosing a CLI comes down to an administrator's preference.
For example, let's take the creation of a vSphere standard virtual switch with vmnic2 as an uplink. All three CLIs have the ability to do it, some in more ways than one. However, the syntax required to get there is different for each.
vicfg-vswitch –server ESXiServerName –username username –password password –a TempSwitch
vicfg-vswitch –server ESXiServerName –username username –password password TempSwitch –L vmnic2
esxcli –server ESXiServerName –username username –password password network vswitch standard add –v TempSwitch
esxcli –server ESXiServerName –username username –password password network vswitch standard uplink add –u vmnic2 –v TempSwitch
esxcfg-vswitch –a TempSwitch
esxcfg-vswitch TempSwitch –L vmnic2
esxcli network vswitch standard add –v TempSwitch
esxcli network vswitch standard uplink add –u vmnic2 –v TempSwitch
New-VirtualSwitch –VMHost ESXiServerName –Name TempSwitch –Nic vmnic2
$esxcli = Get-ESXCLI –VMhost ESXiServerName
Similarities and a caveat
The vCLI and ESXi Shell functions are very similar, with the difference being vCLI requires you to provide the name and credentials of your ESXi host. The ESXi Shell always defaults its credentials to the logged-in local host. Note the vCLI contains esxcfg commands, which are present for backward-compatibility reasons and may be phased out in a future vSphere release. The esxcli namespace commands are available in all three CLIs.
Pick your poison
How do you choose which CLI to use? If you are used to scripting in bash and perl, then the vCLI is probably going to be your best option. If you are more of a Windows and PowerShell person, the PowerCLI cmdlets will be the way to go.
I personally use a combination of all three of them: vCLI when I need to integrate with other native Linux-type commands like grep and sed, ESXi Shell when performing troubleshooting, and PowerCLI for reporting, automation, and pretty much everything else.
Either way, the result will be the same no matter what CLI option you choose; it's simply a matter of comfort.
Dig deeper on Troubleshooting VMware products
Mike Preston asks:
Which CLI do you prefer to use?
1 ResponseJoin the Discussion
Related Q&A from Mike Preston
What is an OVA file and how does it compare to an Open Virtualization Format package?continue reading
With a little manipulation via SSH or ESXi Shell, a locked core dump file can soon be just a distant memory for your ESXi environment.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.