Essential Guide

Top tools and techniques for VMware automation

A comprehensive collection of articles, videos and more, hand-picked by our editors
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 last published in April 2014

Essential Guide

Top tools and techniques for VMware automation

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.

Join the conversation

4 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

Which CLI do you prefer to use?
Cancel
Powerful tool, and is often more efficient and offers more options than the relevant GUI works anywhere uses less bandwidth and you can script stuff
Cancel
Power CLI is good for troubleshooting
Cancel
Before you can use the IBM Storage Enhancements for VMware vSphere Web Client on the web client side, you need to define on the IBM Storage Integration Server side the vCenter servers for which you want to provide storage resources attach storage pools that you want to make available to each vCenter server Use the vwc_vcenter and vwc_poolCLI commands to add, modify, remove, or list vCenter servers, and also to attach or detach storage pools that were predefined on the IBM storage systems you have added. The vwc_host command is required for ESXi host definition on DS8000® arrays
Cancel

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close