Q

Which CLI is best: vSphere CLI, PowerCLI or ESXi Shell?

VMware offers three CLI choices to run commands in a vSphere environment, but which one is the best option?

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.

vCLI

vicfg-vswitch –server ESXiServerName –username username –password password –a TempSwitch

vicfg-vswitch –server ESXiServerName –username username –password password TempSwitch –L vmnic2

OR

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

ESXi Shell

esxcfg-vswitch –a TempSwitch

esxcfg-vswitch TempSwitch –L vmnic2

OR

esxcli network vswitch standard add –v TempSwitch

esxcli network vswitch standard uplink add –u vmnic2 –v TempSwitch

PowerCLI

New-VirtualSwitch –VMHost ESXiServerName –Name TempSwitch –Nic vmnic2

OR

$esxcli = Get-ESXCLI –VMhost ESXiServerName

$esxcli.network.vswitch.standard.add($null,"TempSwitch")

$esxcli network.vswitch.standard.uplink.add("vmnic2","TempSwitch")

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.

This was first published in April 2014

Dig deeper on Troubleshooting VMware products

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.
Related Discussions

Mike Preston asks:

Which CLI do you prefer to use?

1  Response So Far

Join the Discussion

1 comment

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close