Skip to content

vSphere 6.0 - How to use ESXCLI Commands in PowerCLI

PowerCLI, a set of PowerShell extensions for vSphere, is a great tool for automating VMware configuration and management tasks. It allows you to change a lot of ESXi host and vCenter settings. One powerful cmdlet is Get-EsxCli which allows you to run ESXCLI tasks from your PowerCLI console. ESXCLI is the main configuration command on an ESXi host. This post explains how to use the Get-EsxCli cmdlet.

get-esxcli

[This post is outdated. A new version is available here]

Getting Started with Get-ESXCli

First of all, grab the latest version of vSphere PowerCLI 6.0. Connect to the vCenter Server or an ESXi Host directly and run the following command. This will create an object that you can run commands against.

$esxcli = Get-EsxCli -VMhost esx01.virten.lab

The $esxcli variable can now be used in the same way as the esxcli command on an ESXi host. You can list all available namespaces by printing the variable:

PS C:\> $esxcli

=======================
EsxCli: 192.168.0.20

   Elements:
   ---------
   device
   elxnet
   esxcli
   fcoe
   graphics
   hardware
   iscsi
   network
   rdma
   sched
   software
   storage
   system
   vm
   vsan

To crawl through namespaces you can append any element to the $esxcli variable like you know it from esxcli. The only difference is that in PowerCLI the namespace is separated by a dot instead of a blank.

PS C:\> $esxcli.vm

=================
EsxCliElement: vm

   Elements:
   ---------
   process

At some point you see methods instead of elements. This is where you actually run commands.

PS C:\esx> $esxcli.vm.process

======================
EsxCliElement: process

   Methods:
   --------
   boolean kill(string type, long worldid)
   VirtualMachine[] list()

The output above has two methods, kill and list. The list command does not require any variables, so you can use it directely:

PS C:\> $esxcli.vm.process.list()

ConfigFile  : /vmfs/volumes/173c1f45-a9d8f929/vcsa6.virten.lab/vcsa6.virten.lab.vmx
DisplayName : vcsa6.virten.lab
ProcessID   : 0
UUID        : 56 4d 51 02 b7 e0 e3 a1-37 5e d5 7b fa a0 a2 6f
VMXCartelID : 302680
WorldID     : 302681

The output can be used in the same way as you know from PowerShell:

PS C:\esx> $esxcli.vm.process.list() |select DisplayName

DisplayName
-----------
vcsa6.virten.lab

With a foreach loop you can run the same esxcli command on many hosts:

$VMhosts = Get-Cluster Cluster |Get-VMHost
foreach($VMhost in $VMhosts){
  $esxcli = get-vmhost $VMhost | Get-EsxCli
  $esxcli.vm.process.list()
}

If a method has parameters you have to know parameters and their sequence. This is how you find out the parameter definition which is different at every command:

PS C:\> $esxcli.system.module.set

TypeNameOfValue     : VMware.VimAutomation.ViCore.Util10Ps.EsxCliExtensionMethod
OverloadDefinitions : {void set(boolean enabled, boolean force, string module)}
MemberType          : CodeMethod
Value               : void set(boolean enabled, boolean force, string module)
Name                : set
IsInstance          : True

This is the section we are looking for:
esxcli-powercli

In that case, we have to define 3 variables: Enabled (boolean), force (boolean) and module (string). As an example, I am going to disable the lldp module:

  • enable (boolean): $false <-- This will disable the module
  • force (Boolean): $false <-- This will not try to force the commands execution
  • module (string): "lldp" <-- The name of the module to disable

Build the command:

PS C:\> $esxcli.system.module.set($false, $false, "lldp")

To build that commands for all methods, you have to know how to use the 3 data types string, long and boolean:

  • string - Any words or names. Quotes are required.
  • long - A number
  • boolean - Can be $false or $true

Non-required parameters can be set to $null

In that example I'm setting a multipath rule for a device:

PS C:\> $esxcli.storage.nmp.device.set
Value : boolean set(boolean default, string device, string psp)

Build the command:

PS C:\> $esxcli.storage.nmp.device.set($null, "naa.xxx", "VMW_PSP_MRU")

This are all valid esxcli commands in ESXi 6.0

$esxcli.device.add(string deviceidentifier, long instanceaddress)
$esxcli.elxnet.dbgmask.get(string pcidevname)
$esxcli.elxnet.dbgmask.set(string mask, string pcidevname)
$esxcli.elxnet.regdump.get(string filepath, string pcidevname)
$esxcli.elxnet.stats.get(string pcidevname)
$esxcli.elxnet.vib.get()
$esxcli.esxcli.command.list()
$esxcli.fcoe.adapter.list()
$esxcli.fcoe.nic.disable(string nicname)
$esxcli.fcoe.nic.discover(string nicname)
$esxcli.fcoe.nic.list()
$esxcli.fcoe.nic.set(boolean enablevn2vn, string nicname, long vlanid)
$esxcli.graphics.device.list()
$esxcli.graphics.vm.list()
$esxcli.hardware.bootdevice.list()
$esxcli.hardware.clock.get()
$esxcli.hardware.clock.set(long day, long hour, long min, long month, long sec, long year)
$esxcli.hardware.cpu.cpuid.get(long cpu)
$esxcli.hardware.cpu.global.get()
$esxcli.hardware.cpu.global.set(boolean hyperthreading)
$esxcli.hardware.cpu.list()
$esxcli.hardware.ipmi.fru.get(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.fru.list(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.sdr.get(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.sdr.list(string formatter, boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.sel.clear(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.sel.get(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.sel.list(boolean ignoremissing, boolean includeprettyraw, boolean includeraw, string node)
$esxcli.hardware.ipmi.help()
$esxcli.hardware.memory.get()
$esxcli.hardware.pci.list(string class, string mask)
$esxcli.hardware.platform.get()
$esxcli.hardware.smartcard.certificate.list(long slot)
$esxcli.hardware.smartcard.info.get()
$esxcli.hardware.smartcard.slot.list()
$esxcli.hardware.smartcard.token.list(long slot)
$esxcli.hardware.smartcard.help()
$esxcli.hardware.trustedboot.get()
$esxcli.iscsi.adapter.auth.chap.get(string adapter, string direction)
$esxcli.iscsi.adapter.auth.chap.set(string adapter, string authname, boolean default, string direction, string level, string secret)
$esxcli.iscsi.adapter.auth.help()
$esxcli.iscsi.adapter.capabilities.get(string adapter)
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.get(string adapter, string address, string direction)
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.set(string adapter, string address, string authname, boolean default, string direction, boolean inherit, string level, string secret)
$esxcli.iscsi.adapter.discovery.sendtarget.auth.help()
$esxcli.iscsi.adapter.discovery.sendtarget.param.get(string adapter, string address)
$esxcli.iscsi.adapter.discovery.sendtarget.param.set(string adapter, string address, boolean default, boolean inherit, string key, string value)
$esxcli.iscsi.adapter.discovery.sendtarget.add(string adapter, string address)
$esxcli.iscsi.adapter.discovery.sendtarget.list(string adapter)
$esxcli.iscsi.adapter.discovery.sendtarget.remove(string adapter, string address)
$esxcli.iscsi.adapter.discovery.statictarget.add(string adapter, string address, string name)
$esxcli.iscsi.adapter.discovery.statictarget.list(string adapter)
$esxcli.iscsi.adapter.discovery.statictarget.remove(string adapter, string address, string name)
$esxcli.iscsi.adapter.discovery.status.get(string adapter)
$esxcli.iscsi.adapter.discovery.rediscover(string adapter)
$esxcli.iscsi.adapter.firmware.get(string adapter, string file)
$esxcli.iscsi.adapter.firmware.set(string adapter, string file)
$esxcli.iscsi.adapter.param.get(string adapter)
$esxcli.iscsi.adapter.param.set(string adapter, boolean default, string key, string value)
$esxcli.iscsi.adapter.target.portal.auth.chap.get(string adapter, string address, string direction, string method, string name)
$esxcli.iscsi.adapter.target.portal.auth.chap.set(string adapter, string address, string authname, boolean default, string direction, boolean inherit, string level, string name, string secret)
$esxcli.iscsi.adapter.target.portal.auth.help()
$esxcli.iscsi.adapter.target.portal.param.get(string adapter, string address, string name)
$esxcli.iscsi.adapter.target.portal.param.set(string adapter, string address, boolean default, boolean inherit, string key, string name, string value)
$esxcli.iscsi.adapter.target.portal.list(string adapter, string name)
$esxcli.iscsi.adapter.target.list(string adapter, string name)
$esxcli.iscsi.adapter.get(string adapter)
$esxcli.iscsi.adapter.list(string adapter)
$esxcli.iscsi.adapter.set(string adapter, string alias, string name)
$esxcli.iscsi.ibftboot.get()
$esxcli.iscsi.ibftboot.import()
$esxcli.iscsi.logicalnetworkportal.list(string adapter)
$esxcli.iscsi.networkportal.ipconfig.get(string adapter, string nic)
$esxcli.iscsi.networkportal.ipconfig.set(string adapter, string dns1, string dns2, boolean enable, boolean enabledhcpv4, string gateway, string ip, string nic, string subnet)
$esxcli.iscsi.networkportal.ipv6config.address.add(string adapter, string[] addresslist, boolean removeallexisting)
$esxcli.iscsi.networkportal.ipv6config.address.list(string adapter)
$esxcli.iscsi.networkportal.ipv6config.address.remove(string adapter, string[] addresslist)
$esxcli.iscsi.networkportal.ipv6config.get(string adapter)
$esxcli.iscsi.networkportal.ipv6config.set(string adapter, boolean enable, boolean enabledhcpv6, boolean enablelinklocalautoconfiguration, boolean enablerouteradvertisement, string gateway6)
$esxcli.iscsi.networkportal.add(string adapter, boolean force, string nic)
$esxcli.iscsi.networkportal.list(string adapter)
$esxcli.iscsi.networkportal.remove(string adapter, boolean force, string nic)
$esxcli.iscsi.physicalnetworkportal.param.get(string adapter, string nic)
$esxcli.iscsi.physicalnetworkportal.param.set(string adapter, string nic, string option, long value)
$esxcli.iscsi.physicalnetworkportal.list(string adapter)
$esxcli.iscsi.plugin.list(string adapter, string plugin)
$esxcli.iscsi.session.connection.list(string adapter, string cid, string isid, string name)
$esxcli.iscsi.session.add(string adapter, string isid, string name)
$esxcli.iscsi.session.list(string adapter, string isid, string name)
$esxcli.iscsi.session.remove(string adapter, string isid, string name)
$esxcli.iscsi.software.get()
$esxcli.iscsi.software.set(boolean enabled)
$esxcli.network.diag.ping(long count, boolean debug, boolean df, string host, string interface, string interval, boolean ipv4, boolean ipv6, string netstack, string nexthop, long size, long ttl, string wait)
$esxcli.network.firewall.ruleset.allowedip.add(string ipaddress, string rulesetid)
$esxcli.network.firewall.ruleset.allowedip.list(string rulesetid)
$esxcli.network.firewall.ruleset.allowedip.remove(string ipaddress, string rulesetid)
$esxcli.network.firewall.ruleset.rule.list(string rulesetid)
$esxcli.network.firewall.ruleset.list(string rulesetid)
$esxcli.network.firewall.ruleset.set(boolean allowedall, boolean enabled, string rulesetid)
$esxcli.network.firewall.get()
$esxcli.network.firewall.load()
$esxcli.network.firewall.refresh()
$esxcli.network.firewall.set(boolean defaultaction, boolean enabled)
$esxcli.network.firewall.unload()
$esxcli.network.ip.connection.list(string netstack, string type)
$esxcli.network.ip.dns.search.add(string domain, string netstack)
$esxcli.network.ip.dns.search.list(string netstack)
$esxcli.network.ip.dns.search.remove(string domain, string netstack)
$esxcli.network.ip.dns.server.add(string netstack, string server)
$esxcli.network.ip.dns.server.list(string netstack)
$esxcli.network.ip.dns.server.remove(boolean all, string netstack, string server)
$esxcli.network.ip.dns.help()
$esxcli.network.ip.interface.ipv4.get(string interfacename, string netstack)
$esxcli.network.ip.interface.ipv4.set(string interfacename, string ipv4, string netmask, boolean peerdns, string type)
$esxcli.network.ip.interface.ipv6.address.add(string interfacename, string ipv6)
$esxcli.network.ip.interface.ipv6.address.list(string interfacename)
$esxcli.network.ip.interface.ipv6.address.remove(string interfacename, string ipv6)
$esxcli.network.ip.interface.ipv6.get(string interfacename, string netstack)
$esxcli.network.ip.interface.ipv6.set(boolean enabledhcpv6, boolean enablerouteradv, string interfacename, boolean peerdns)
$esxcli.network.ip.interface.tag.add(string interfacename, string tagname)
$esxcli.network.ip.interface.tag.get(string interfacename)
$esxcli.network.ip.interface.tag.remove(string interfacename, string tagname)
$esxcli.network.ip.interface.add(string dvportid, string dvsname, string interfacename, string macaddress, long mtu, string netstack, string portgroupname)
$esxcli.network.ip.interface.list(string netstack)
$esxcli.network.ip.interface.remove(string dvportid, string dvsname, string interfacename, string netstack, string portgroupname)
$esxcli.network.ip.interface.set(boolean enabled, string interfacename, long mtu)
$esxcli.network.ip.ipsec.sa.add(string encryptionalgorithm, string encryptionkey, string integrityalgorithm, string integritykey, string sadestination, string samode, string saname, string sasource, string saspi)
$esxcli.network.ip.ipsec.sa.list()
$esxcli.network.ip.ipsec.sa.remove(boolean removeall, string sadestination, string saname, string sasource, string saspi)
$esxcli.network.ip.ipsec.sp.add(string action, long destinationport, string flowdirection, string saname, long sourceport, string spdestination, string spmode, string spname, string spsource, string upperlayerprotocol)
$esxcli.network.ip.ipsec.sp.list()
$esxcli.network.ip.ipsec.sp.remove(boolean removeall, string spname)
$esxcli.network.ip.ipsec.set(string ikeconf)
$esxcli.network.ip.neighbor.list(string interfacename, string netstack, string version)
$esxcli.network.ip.neighbor.remove(string interfacename, string neighboraddr, string netstack, string version)
$esxcli.network.ip.netstack.add(boolean disabled, string netstack)
$esxcli.network.ip.netstack.get(string netstack)
$esxcli.network.ip.netstack.list()
$esxcli.network.ip.netstack.remove(string netstack)
$esxcli.network.ip.netstack.set(string ccalgo, boolean enable, boolean ipv6enabled, long maxconn, string name, string netstack)
$esxcli.network.ip.route.ipv4.add(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv4.list(string netstack)
$esxcli.network.ip.route.ipv4.remove(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv6.add(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv6.list(string netstack)
$esxcli.network.ip.route.ipv6.remove(string gateway, string netstack, string network)
$esxcli.network.ip.route.help()
$esxcli.network.ip.get()
$esxcli.network.ip.set(boolean ipv6enabled)
$esxcli.network.nic.coalesce.get(string vmnic)
$esxcli.network.nic.coalesce.set(boolean adaptiverx, boolean adaptivetx, long rxmaxframes, long rxusecs, long sampleinterval, long txmaxframes, long txusecs, string vmnic)
$esxcli.network.nic.cso.get(string vmnic)
$esxcli.network.nic.cso.set(long enable, string vmnic)
$esxcli.network.nic.eeprom.change(string file, long magic, long offset, long value, string vmnic)
$esxcli.network.nic.eeprom.dump(long length, long offset, string vmnic)
$esxcli.network.nic.negotiate.restart(string vmnic)
$esxcli.network.nic.pauseParams.list(string nicname)
$esxcli.network.nic.pauseParams.set(boolean auto, string nicname, boolean rx, boolean tx)
$esxcli.network.nic.register.dump(string vmnic)
$esxcli.network.nic.ring.current.get(string nicname)
$esxcli.network.nic.ring.current.set(string nicname, long rx, long rxjumbo, long rxmini, long tx)
$esxcli.network.nic.ring.preset.get(string nicname)
$esxcli.network.nic.ring.help()
$esxcli.network.nic.selftest.run(long online, string vmnic)
$esxcli.network.nic.sg.get(string vmnic)
$esxcli.network.nic.sg.set(long enable, string vmnic)
$esxcli.network.nic.software.list()
$esxcli.network.nic.software.set(boolean geneveoffload, boolean highdma, boolean ipv4cso, boolean ipv4tso, boolean ipv6cso, boolean ipv6csoext, boolean ipv6tso, boolean ipv6tsoext, boolean obo, boolean sg, boolean sgsp, boolean tagging, boolean untagging, string vmnic, boolean vxlanencap)
$esxcli.network.nic.stats.get(string nicname)
$esxcli.network.nic.tso.get(string vmnic)
$esxcli.network.nic.tso.set(long enable, string vmnic)
$esxcli.network.nic.vlan.stats.get(string nicname)
$esxcli.network.nic.vlan.stats.set(boolean enabled, string nicname)
$esxcli.network.nic.vlan.help()
$esxcli.network.nic.down(string nicname)
$esxcli.network.nic.get(string nicname)
$esxcli.network.nic.list()
$esxcli.network.nic.set(boolean auto, string duplex, long messagelevel, string nicname, long phyaddress, string port, long speed, string transceivertype, string wakeonlan)
$esxcli.network.nic.up(string nicname)
$esxcli.network.port.filter.stats.get(long portid)
$esxcli.network.port.filter.help()
$esxcli.network.port.stats.get(long portid)
$esxcli.network.port.help()
$esxcli.network.sriovnic.vf.list(string nicname)
$esxcli.network.sriovnic.vf.stats(string nicname, long vfid)
$esxcli.network.sriovnic.list()
$esxcli.network.vm.port.list(long worldid)
$esxcli.network.vm.list()
$esxcli.network.vswitch.dvs.vmware.lacp.config.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.stats.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.status.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.timeout.set(long lagid, string nicname, boolean timeout, string vds)
$esxcli.network.vswitch.dvs.vmware.lacp.help()
$esxcli.network.vswitch.dvs.vmware.list(string vdsname)
$esxcli.network.vswitch.dvs.help()
$esxcli.network.vswitch.standard.policy.failover.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.failover.set(string activeuplinks, boolean failback, string failuredetection, string loadbalancing, boolean notifyswitches, string standbyuplinks, string vswitchname)
$esxcli.network.vswitch.standard.policy.security.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.security.set(boolean allowforgedtransmits, boolean allowmacchange, boolean allowpromiscuous, string vswitchname)
$esxcli.network.vswitch.standard.policy.shaping.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.shaping.set(long avgbandwidth, long burstsize, boolean enabled, long peakbandwidth, string vswitchname)
$esxcli.network.vswitch.standard.policy.help()
$esxcli.network.vswitch.standard.portgroup.policy.failover.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.failover.set(string activeuplinks, boolean failback, string failuredetection, string loadbalancing, boolean notifyswitches, string portgroupname, string standbyuplinks, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.security.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.security.set(boolean allowforgedtransmits, boolean allowmacchange, boolean allowpromiscuous, string portgroupname, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.shaping.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.shaping.set(long avgbandwidth, long burstsize, boolean enabled, long peakbandwidth, string portgroupname, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.help()
$esxcli.network.vswitch.standard.portgroup.add(string portgroupname, string vswitchname)
$esxcli.network.vswitch.standard.portgroup.list()
$esxcli.network.vswitch.standard.portgroup.remove(string portgroupname, string vswitchname)
$esxcli.network.vswitch.standard.portgroup.set(string portgroupname, long vlanid)
$esxcli.network.vswitch.standard.uplink.add(string uplinkname, string vswitchname)
$esxcli.network.vswitch.standard.uplink.remove(string uplinkname, string vswitchname)
$esxcli.network.vswitch.standard.add(long ports, string vswitchname)
$esxcli.network.vswitch.standard.list(string vswitchname)
$esxcli.network.vswitch.standard.remove(string vswitchname)
$esxcli.network.vswitch.standard.set(string cdpstatus, long mtu, string vswitchname)
$esxcli.network.vswitch.help()
$esxcli.rdma.device.stats.get(string device)
$esxcli.rdma.device.vmknic.list(string device)
$esxcli.rdma.device.list()
$esxcli.sched.reliablemem.get()
$esxcli.sched.swap.system.get()
$esxcli.sched.swap.system.set(boolean datastoreenabled, string datastorename, long datastoreorder, boolean hostcacheenabled, long hostcacheorder, boolean hostlocalswapenabled, long hostlocalswaporder)
$esxcli.sched.swap.help()
$esxcli.software.acceptance.get()
$esxcli.software.acceptance.set(string level)
$esxcli.software.profile.get(boolean rebootingimage)
$esxcli.software.profile.install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, boolean oktoremove, string profile, string proxy)
$esxcli.software.profile.update(boolean allowdowngrades, string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string profile, string proxy)
$esxcli.software.profile.validate(string[] depot, string profile, string proxy)
$esxcli.software.sources.profile.get(string[] depot, string profile, string proxy)
$esxcli.software.sources.profile.list(string[] depot, string proxy)
$esxcli.software.sources.vib.get(string[] depot, string proxy, string[] vibname, string[] viburl)
$esxcli.software.sources.vib.list(string[] depot, string proxy)
$esxcli.software.sources.help()
$esxcli.software.vib.get(boolean rebootingimage, string[] vibname)
$esxcli.software.vib.install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)
$esxcli.software.vib.list(boolean rebootingimage)
$esxcli.software.vib.remove(boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, string[] vibname)
$esxcli.software.vib.update(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)
$esxcli.storage.core.adapter.stats.get(string adapter)
$esxcli.storage.core.adapter.list()
$esxcli.storage.core.adapter.rescan(string adapter, boolean all, boolean skipclaim, boolean skipfsscan, string type)
$esxcli.storage.core.claiming.autoclaim(string claimruleclass, boolean enabled, boolean wait)
$esxcli.storage.core.claiming.reclaim(string device)
$esxcli.storage.core.claiming.unclaim(string adapter, long channel, string claimruleclass, string device, string driver, long lun, string model, string path, string plugin, long target, string type, string vendor)
$esxcli.storage.core.claimrule.add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, string ifunset, string iqn, long lun, string model, string plugin, long rule, long target, string transport, string type, string vendor, string wwnn, string wwpn, long xcopymaxtransfersize, boolean xcopyusearrayvalues, boolean xcopyusemultisegs)
$esxcli.storage.core.claimrule.convert(boolean commit)
$esxcli.storage.core.claimrule.list(string claimruleclass)
$esxcli.storage.core.claimrule.load(string claimruleclass)
$esxcli.storage.core.claimrule.move(string claimruleclass, long newrule, long rule)
$esxcli.storage.core.claimrule.remove(string claimruleclass, string plugin, long rule)
$esxcli.storage.core.claimrule.run(string adapter, long channel, string claimruleclass, string device, long lun, string path, long target, string type, boolean wait)
$esxcli.storage.core.device.detached.list(string device)
$esxcli.storage.core.device.detached.remove(boolean all, string device)
$esxcli.storage.core.device.partition.list(string device)
$esxcli.storage.core.device.partition.showguid(string device)
$esxcli.storage.core.device.physical.get(string device)
$esxcli.storage.core.device.raid.list(string device)
$esxcli.storage.core.device.smart.get(string devicename)
$esxcli.storage.core.device.stats.get(string device)
$esxcli.storage.core.device.vaai.status.get(string device)
$esxcli.storage.core.device.vaai.help()
$esxcli.storage.core.device.world.list(string device)
$esxcli.storage.core.device.list(string device, boolean excludeoffline, boolean peonly)
$esxcli.storage.core.device.set(boolean dataintegrityenabled, boolean defaultname, string device, boolean force, long ledduration, string ledstate, long maxqueuedepth, string name, boolean nopersist, long queuefullsamplesize, long queuefullthreshold, long schednumreqoutstanding, string state, boolean writecacheenabled)
$esxcli.storage.core.device.setconfig(boolean detached, string device, boolean perenniallyreserved, boolean sharedclusterwide)
$esxcli.storage.core.path.stats.get(string path)
$esxcli.storage.core.path.list(string device, string path)
$esxcli.storage.core.path.set(string path, string state)
$esxcli.storage.core.plugin.registration.add(string dependencies, string fullpath, string modulename, string pluginclass, string pluginname)
$esxcli.storage.core.plugin.registration.list(string modulename, string pluginclass)
$esxcli.storage.core.plugin.registration.remove(string modulename)
$esxcli.storage.core.plugin.list(string pluginclass)
$esxcli.storage.core.help()
$esxcli.storage.filesystem.automount()
$esxcli.storage.filesystem.list(boolean ignoreerrors)
$esxcli.storage.filesystem.mount(boolean nopersist, string volumelabel, string volumeuuid)
$esxcli.storage.filesystem.rescan()
$esxcli.storage.filesystem.unmount(boolean nopersist, string volumelabel, string volumepath, string volumeuuid)
$esxcli.storage.nfs.param.get(string volumename)
$esxcli.storage.nfs.param.set(long maxqueuedepth, string volumename)
$esxcli.storage.nfs.add(string host, boolean ispe, boolean readonly, string share, string volumename)
$esxcli.storage.nfs.list(boolean peonly)
$esxcli.storage.nfs.remove(string volumename)
$esxcli.storage.nfs41.param.get(string volumename)
$esxcli.storage.nfs41.param.set(long maxqueuedepth, string volumename)
$esxcli.storage.nfs41.add(string[] hosts, boolean readonly, string sec, string share, string volumename)
$esxcli.storage.nfs41.list(boolean peonly)
$esxcli.storage.nfs41.remove(string volumename)
$esxcli.storage.nmp.device.list(string device)
$esxcli.storage.nmp.device.set(boolean default, string device, string psp)
$esxcli.storage.nmp.path.list(string device, string path)
$esxcli.storage.nmp.psp.fixed.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.fixed.deviceconfig.set(boolean cfgfile, boolean default, string device, string path)
$esxcli.storage.nmp.psp.fixed.help()
$esxcli.storage.nmp.psp.generic.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.generic.deviceconfig.set(boolean cfgfile, string config, string device)
$esxcli.storage.nmp.psp.generic.pathconfig.get(string path)
$esxcli.storage.nmp.psp.generic.pathconfig.set(boolean cfgfile, string config, string path)
$esxcli.storage.nmp.psp.generic.help()
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(long bytes, boolean cfgfile, string device, long iops, string type, boolean useano)
$esxcli.storage.nmp.psp.roundrobin.help()
$esxcli.storage.nmp.psp.list()
$esxcli.storage.nmp.satp.generic.deviceconfig.get(string device, boolean excludetpginfo)
$esxcli.storage.nmp.satp.generic.deviceconfig.set(string config, string device)
$esxcli.storage.nmp.satp.generic.pathconfig.get(string path)
$esxcli.storage.nmp.satp.generic.pathconfig.set(string config, string path)
$esxcli.storage.nmp.satp.generic.help()
$esxcli.storage.nmp.satp.rule.add(boolean boot, string claimoption, string description, string device, string driver, boolean force, string model, string option, string psp, string pspoption, string satp, string transport, string type, string vendor)
$esxcli.storage.nmp.satp.rule.list(string satp)
$esxcli.storage.nmp.satp.rule.remove(boolean boot, string claimoption, string description, string device, string driver, string model, string option, string psp, string pspoption, string satp, string transport, string type, string vendor)
$esxcli.storage.nmp.satp.list()
$esxcli.storage.nmp.satp.set(boolean boot, string defaultpsp, string satp)
$esxcli.storage.nmp.help()
$esxcli.storage.san.fc.events.clear(string adapter)
$esxcli.storage.san.fc.events.get(string adapter)
$esxcli.storage.san.fc.stats.get(string adapter)
$esxcli.storage.san.fc.list(string adapter)
$esxcli.storage.san.fc.reset(string adapter)
$esxcli.storage.san.fcoe.stats.get(string adapter)
$esxcli.storage.san.fcoe.list(string adapter)
$esxcli.storage.san.fcoe.reset(string adapter)
$esxcli.storage.san.iscsi.stats.get(string adapter)
$esxcli.storage.san.iscsi.list(string adapter)
$esxcli.storage.san.sas.stats.get(string adapter)
$esxcli.storage.san.sas.list(string adapter)
$esxcli.storage.san.sas.reset(string adapter)
$esxcli.storage.san.help()
$esxcli.storage.vflash.cache.stats.get(string cachename, string modulename)
$esxcli.storage.vflash.cache.stats.reset(string cachename, string modulename)
$esxcli.storage.vflash.cache.get(string cachename, string modulename)
$esxcli.storage.vflash.cache.list(string modulename)
$esxcli.storage.vflash.device.list(boolean eligible, boolean used)
$esxcli.storage.vflash.module.stats.get(string modulename)
$esxcli.storage.vflash.module.get(string modulename)
$esxcli.storage.vflash.module.list()
$esxcli.storage.vflash.help()
$esxcli.storage.vmfs.extent.list()
$esxcli.storage.vmfs.host.list(string liveness, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.lockmode.list(boolean ignoreerrors, string[] volumelabel, string[] volumeuuid)
$esxcli.storage.vmfs.lockmode.set(boolean ats, boolean scsi, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.pbcache.get()
$esxcli.storage.vmfs.pbcache.reset()
$esxcli.storage.vmfs.snapshot.extent.list(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.list(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.mount(boolean nopersist, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.resignature(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.unmap(long reclaimunit, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.upgrade(string volumelabel, string volumeuuid)
$esxcli.storage.vvol.daemon.unbindall()
$esxcli.storage.vvol.protocolendpoint.list(string pe)
$esxcli.storage.vvol.storagecontainer.abandonedvvol.scan(string path)
$esxcli.storage.vvol.storagecontainer.list()
$esxcli.storage.vvol.vasacontext.get()
$esxcli.storage.vvol.vasaprovider.list()
$esxcli.storage.vvol.help()
$esxcli.system.account.add(string description, string id, string password, string passwordconfirmation)
$esxcli.system.account.list()
$esxcli.system.account.remove(string id)
$esxcli.system.account.set(string description, string id, string password, string passwordconfirmation)
$esxcli.system.boot.device.get()
$esxcli.system.boot.help()
$esxcli.system.coredump.file.add(boolean auto, string datastore, boolean enable, string file, long size)
$esxcli.system.coredump.file.get()
$esxcli.system.coredump.file.list()
$esxcli.system.coredump.file.remove(string file, boolean force)
$esxcli.system.coredump.file.set(boolean enable, string path, boolean smart, boolean unconfigure)
$esxcli.system.coredump.network.check()
$esxcli.system.coredump.network.get()
$esxcli.system.coredump.network.set(boolean enable, string interfacename, string serverip, string serveripv4, long serverport)
$esxcli.system.coredump.partition.get()
$esxcli.system.coredump.partition.list()
$esxcli.system.coredump.partition.set(boolean enable, string partition, boolean smart, boolean unconfigure)
$esxcli.system.coredump.help()
$esxcli.system.hostname.get()
$esxcli.system.hostname.set(string domain, string fqdn, string host)
$esxcli.system.maintenanceMode.get()
$esxcli.system.maintenanceMode.set(boolean enable, long timeout, string vsanmode)
$esxcli.system.module.parameters.copy(boolean force, string[] parameterkeys, string source, string target)
$esxcli.system.module.parameters.list(string module)
$esxcli.system.module.parameters.set(boolean append, boolean force, string module, string parameterstring)
$esxcli.system.module.get(string module)
$esxcli.system.module.list(boolean enabled, boolean loaded)
$esxcli.system.module.load(boolean force, string module)
$esxcli.system.module.set(boolean enabled, boolean force, string module)
$esxcli.system.permission.list()
$esxcli.system.permission.set(boolean group, string id, string role)
$esxcli.system.permission.unset(boolean group, string id)
$esxcli.system.process.stats.load.get()
$esxcli.system.process.stats.running.get()
$esxcli.system.process.stats.help()
$esxcli.system.process.list()
$esxcli.system.secpolicy.domain.list()
$esxcli.system.secpolicy.domain.set(boolean alldomains, string level, string name)
$esxcli.system.secpolicy.help()
$esxcli.system.security.certificatestore.add(string filename)
$esxcli.system.security.certificatestore.list()
$esxcli.system.security.certificatestore.remove(string issuer, string serial)
$esxcli.system.security.help()
$esxcli.system.settings.advanced.list(boolean delta, string option, string tree)
$esxcli.system.settings.advanced.set(boolean default, long intvalue, string option, string stringvalue)
$esxcli.system.settings.kernel.list(boolean delta, string option)
$esxcli.system.settings.kernel.set(string setting, string value)
$esxcli.system.settings.keyboard.layout.get()
$esxcli.system.settings.keyboard.layout.list()
$esxcli.system.settings.keyboard.layout.set(string layout, boolean nopersist)
$esxcli.system.settings.keyboard.help()
$esxcli.system.settings.help()
$esxcli.system.shutdown.poweroff(long delay, string reason)
$esxcli.system.shutdown.reboot(long delay, string reason)
$esxcli.system.slp.stats.get()
$esxcli.system.slp.search(string node, long port, string protocol, string service)
$esxcli.system.snmp.get()
$esxcli.system.snmp.hash(string authhash, string privhash, boolean rawsecret)
$esxcli.system.snmp.set(string authentication, string communities, boolean enable, string engineid, string hwsrc, boolean largestorage, string loglevel, string notraps, long port, string privacy, string remoteusers, boolean reset, string syscontact, string syslocation, string targets, string users, string v3targets)
$esxcli.system.snmp.test(string authhash, string privhash, boolean rawsecret, string user)
$esxcli.system.stats.uptime.get()
$esxcli.system.stats.help()
$esxcli.system.syslog.config.logger.list()
$esxcli.system.syslog.config.logger.set(string id, string reset, long rotate, long size)
$esxcli.system.syslog.config.get()
$esxcli.system.syslog.config.set(boolean checksslcerts, long defaultrotate, long defaultsize, long defaulttimeout, long droplogrotate, long droplogsize, string logdir, boolean logdirunique, string loghost, long queuedropmark, string reset)
$esxcli.system.syslog.mark(string message)
$esxcli.system.syslog.reload()
$esxcli.system.time.get()
$esxcli.system.time.set(long day, long hour, long min, long month, long sec, long year)
$esxcli.system.uuid.get()
$esxcli.system.version.get()
$esxcli.system.visorfs.ramdisk.add(long maxsize, long minsize, string name, string permissions, string target)
$esxcli.system.visorfs.ramdisk.list()
$esxcli.system.visorfs.ramdisk.remove(string target)
$esxcli.system.visorfs.tardisk.list()
$esxcli.system.visorfs.get()
$esxcli.system.welcomemsg.get()
$esxcli.system.welcomemsg.set(string message)
$esxcli.vm.process.kill(string type, long worldid)
$esxcli.vm.process.list()
$esxcli.vsan.cluster.get()
$esxcli.vsan.cluster.join(string clusteruuid, boolean wait)
$esxcli.vsan.cluster.leave()
$esxcli.vsan.cluster.new()
$esxcli.vsan.cluster.restore(boolean boot)
$esxcli.vsan.datastore.name.get()
$esxcli.vsan.datastore.name.set(string newname)
$esxcli.vsan.datastore.help()
$esxcli.vsan.faultdomain.get()
$esxcli.vsan.faultdomain.reset()
$esxcli.vsan.faultdomain.set(string fdname)
$esxcli.vsan.maintenancemode.cancel()
$esxcli.vsan.network.ipv4.add(string agentmcaddr, long agentmcport, string interfacename, string mastermcaddr, long mastermcport, long multicastttl)
$esxcli.vsan.network.ipv4.remove(boolean force, string interfacename)
$esxcli.vsan.network.ipv4.set(string agentmcaddr, long agentmcport, string interfacename, string mastermcaddr, long mastermcport, long multicastttl)
$esxcli.vsan.network.clear()
$esxcli.vsan.network.list()
$esxcli.vsan.network.remove(boolean force, string interfacename)
$esxcli.vsan.network.restore()
$esxcli.vsan.policy.cleardefault()
$esxcli.vsan.policy.getdefault(string policyclass)
$esxcli.vsan.policy.setdefault(string policy, string policyclass)
$esxcli.vsan.storage.automode.get()
$esxcli.vsan.storage.automode.set(boolean enabled)
$esxcli.vsan.storage.checksum.get()
$esxcli.vsan.storage.checksum.set(boolean enabled)
$esxcli.vsan.storage.diskgroup.mount(string ssd, string uuid)
$esxcli.vsan.storage.diskgroup.unmount(string ssd)
$esxcli.vsan.storage.tag.add(string disk, string tag)
$esxcli.vsan.storage.tag.remove(string disk, string tag)
$esxcli.vsan.storage.add(string[] disks, string ssd)
$esxcli.vsan.storage.list(string device, string uuid)
$esxcli.vsan.storage.remove(string disk, string evacuationmode, string ssd, string uuid)
$esxcli.vsan.trace.set(long numfiles, string path, boolean reset, long size)

7 thoughts on “vSphere 6.0 - How to use ESXCLI Commands in PowerCLI”

  1. Thank you fgrehl for such nice article.

    I am trying to just unmount the Datastores from particluar ESXi host in cluster.

    Using command $esxcli.storage.filesystem.unmount("DataStore01")

    But Below error message received

    Message: A specified parameter was not correct.
    argument[0];
    InnerText: argument[0]
    At line:1 char:1
    + $esxcli.storage.filesystem.unmount("DataStore01")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], InvalidArgument
    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument

    I tried with Naa* no too Still no luck,Can you please Let me know the correct method to pass the value(Datastore Name,Naa ID..Etc) to the command to get it work

    Thank you in Advance

    1. The command format for unmounting datastores with PowerCLI is

      $esxcli.storage.filesystem.unmount(boolean nopersist, string volumelabel, string volumepath, string volumeuuid)

      But this is very uncomfortable. VMware (Alan Renouf) has written functions for datastore unmount/detach operations. You can find them here: https://communities.vmware.com/docs/DOC-18008

  2. I'm getting error while using suggested foreach loop
    "Cannot overwrite variable Host because it is read-only or constant."
    Fixed it by renaming $host -> $hosta

  3. i was able to figure out with V2 how to pull hba max q depth on a host using

    $esxcli.system.module.parameters.list.Invoke(@{module = 'fnic'}) | Select-Object -Property Name, Value | where {$_.Name -eq "fnic_max_qdepth"}

    but i can't seem to figure out based on your example above how would it go about setting "fnic_max_qdepth" to a value of say 64 or 128?

    any help appreciated

    1. i fig it out :) using this post

      https://communities.vmware.com/thread/565787

      basically build parameters

      $Parameters =$esxcliv2.system.module.parameters.set.CreateArgs()

      then name the module and the parameter setting with value and Invoke

      $Parameters.module = 'fnic'
      $Parameters.parameterstring = 'fnic_max_qdepth=30'
      $esxcli.system.module.parameters.set.Invoke($Parameters)

  4. Hi All,

    I'm trying to execute below syntax.

    $esxcli.network.nic.get(string nicname)

    Can you please me how to mention string and nicname.
    My nicname name value is vmnic0.

    Can you please proper command to esecute

Leave a Reply

Your email address will not be published. Required fields are marked *