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.
[This post is outdated. A new version is available here]
Getting Started with Get-ESXCli
To get started with the command you have to load the output to a variable. 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.222.111 Elements: --------- device esxcli fcoe graphics hardware iscsi network 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:\Users\fgr> $esxcli.vm ================= EsxCliElement: vm Elements: --------- process
To execute a command finally, you have to append brackets at the end.
PS C:\> $esxcli.network.nic.list() Description : Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) Driver : e1000 Duplex : Full Link : Up MACAddress : 00:0c:29:84:e7:91 MTU : 1500 Name : vmnic0 PCIDevice : 0000:002:00.0 Speed : 1000
The output can also be used with other PowerShell commands.
PS C:\> $esxcli.network.nic.list() |select Name Name ---- vmnic0
When you want to change configurations on many hosts, you can create a small loop to run the same esxcli command on all hosts:
$hosts = Get-Cluster Cluster |Get-VMHost foreach($vihost in $hosts){ $esxcli = get-vmhost $vihost | Get-EsxCli $esxcli.network.nic.list() }
Using parameters is a little bit tricky as you have to know parameters and their sequence. This is how you find out the parameter definition which is different at each 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:
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")
That's it. To get an overview of all possible esxcli commands, Robert van den Nieuwendijk has written a small script which can be found here. This script display all esxcli commands and their parameter sequence. Very handy!
This are all valid esxcli commands in ESXi 5.5
PS C:\> Get-EsxCliCommand $esxcli $esxcli $esxcli.device $esxcli.device.alias $esxcli.device.alias.get(string alias) $esxcli.device.alias.list() $esxcli.esxcli $esxcli.esxcli.command $esxcli.esxcli.command.list() $esxcli.fcoe $esxcli.fcoe.adapter $esxcli.fcoe.adapter.list() $esxcli.fcoe.nic $esxcli.fcoe.nic.disable(string nicname) $esxcli.fcoe.nic.discover(string nicname) $esxcli.fcoe.nic.list() $esxcli.graphics $esxcli.graphics.device $esxcli.graphics.device.list() $esxcli.graphics.vm $esxcli.graphics.vm.list() $esxcli.hardware $esxcli.hardware.bootdevice $esxcli.hardware.bootdevice.list() $esxcli.hardware.clock $esxcli.hardware.clock.get() $esxcli.hardware.clock.set(long day, long hour, long min, long month, long sec, long year) $esxcli.hardware.cpu $esxcli.hardware.cpu.cpuid $esxcli.hardware.cpu.cpuid.get(long cpu) $esxcli.hardware.cpu.global $esxcli.hardware.cpu.global.get() $esxcli.hardware.cpu.global.set(boolean hyperthreading) $esxcli.hardware.cpu.list() $esxcli.hardware.ipmi $esxcli.hardware.ipmi.fru $esxcli.hardware.ipmi.fru.get(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.fru.list(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.sdr $esxcli.hardware.ipmi.sdr.get(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.sdr.list(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.sel $esxcli.hardware.ipmi.sel.get(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.sel.list(boolean ignoremissing, boolean includeraw, string node) $esxcli.hardware.ipmi.help() $esxcli.hardware.memory $esxcli.hardware.memory.get() $esxcli.hardware.pci $esxcli.hardware.pci.list(string class, string mask) $esxcli.hardware.platform $esxcli.hardware.platform.get() $esxcli.hardware.trustedboot $esxcli.hardware.trustedboot.get() $esxcli.iscsi $esxcli.iscsi.adapter $esxcli.iscsi.adapter.auth $esxcli.iscsi.adapter.auth.chap $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 $esxcli.iscsi.adapter.capabilities.get(string adapter) $esxcli.iscsi.adapter.discovery $esxcli.iscsi.adapter.discovery.sendtarget $esxcli.iscsi.adapter.discovery.sendtarget.auth $esxcli.iscsi.adapter.discovery.sendtarget.auth.chap $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 $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 $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 $esxcli.iscsi.adapter.discovery.status.get(string adapter) $esxcli.iscsi.adapter.discovery.rediscover(string adapter) $esxcli.iscsi.adapter.firmware $esxcli.iscsi.adapter.firmware.get(string adapter, string file) $esxcli.iscsi.adapter.firmware.set(string adapter, string file) $esxcli.iscsi.adapter.param $esxcli.iscsi.adapter.param.get(string adapter) $esxcli.iscsi.adapter.param.set(string adapter, boolean default, string key, string value) $esxcli.iscsi.adapter.target $esxcli.iscsi.adapter.target.portal $esxcli.iscsi.adapter.target.portal.auth $esxcli.iscsi.adapter.target.portal.auth.chap $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 $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 $esxcli.iscsi.ibftboot.get() $esxcli.iscsi.ibftboot.import() $esxcli.iscsi.logicalnetworkportal $esxcli.iscsi.logicalnetworkportal.list(string adapter) $esxcli.iscsi.networkportal $esxcli.iscsi.networkportal.ipconfig $esxcli.iscsi.networkportal.ipconfig.get(string adapter, string nic) $esxcli.iscsi.networkportal.ipconfig.set(string adapter, string dns1, string dns2, string gateway, string ip, string nic, string subnet) $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 $esxcli.iscsi.physicalnetworkportal.param $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 $esxcli.iscsi.plugin.list(string adapter, string plugin) $esxcli.iscsi.session $esxcli.iscsi.session.connection $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 $esxcli.iscsi.software.get() $esxcli.iscsi.software.set(boolean enabled) $esxcli.network $esxcli.network.diag $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.fence $esxcli.network.fence.network $esxcli.network.fence.network.bte $esxcli.network.fence.network.bte.list(long fenceid, string vdsname) $esxcli.network.fence.network.port $esxcli.network.fence.network.port.list(long fenceid, string vdsname) $esxcli.network.fence.network.list(long fenceid, string vdsname) $esxcli.network.fence.list() $esxcli.network.firewall $esxcli.network.firewall.ruleset $esxcli.network.firewall.ruleset.allowedip $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 $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 $esxcli.network.ip.connection $esxcli.network.ip.connection.list(string netstack, string type) $esxcli.network.ip.dns $esxcli.network.ip.dns.search $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 $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 $esxcli.network.ip.interface.ipv4 $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 $esxcli.network.ip.interface.ipv6.address $esxcli.network.ip.interface.ipv6.address.add(string interfacename, string ipv6) $esxcli.network.ip.interface.ipv6.address.list() $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 $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 $esxcli.network.ip.ipsec.sa $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 $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 $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 $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 $esxcli.network.ip.route.ipv4 $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 $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 $esxcli.network.nic.coalesce $esxcli.network.nic.coalesce.get(string vmnic) $esxcli.network.nic.coalesce.set(long rxmaxframes, long rxusecs, long txmaxframes, long txusecs, string vmnic) $esxcli.network.nic.cso $esxcli.network.nic.cso.get(string vmnic) $esxcli.network.nic.cso.set(long enable, string vmnic) $esxcli.network.nic.eeprom $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 $esxcli.network.nic.negotiate.restart(string vmnic) $esxcli.network.nic.register $esxcli.network.nic.register.dump(string vmnic) $esxcli.network.nic.selftest $esxcli.network.nic.selftest.run(long online, string vmnic) $esxcli.network.nic.sg $esxcli.network.nic.sg.get(string vmnic) $esxcli.network.nic.sg.set(long enable, string vmnic) $esxcli.network.nic.stats $esxcli.network.nic.stats.get(string nicname) $esxcli.network.nic.tso $esxcli.network.nic.tso.get(string vmnic) $esxcli.network.nic.tso.set(long enable, string vmnic) $esxcli.network.nic.vlan $esxcli.network.nic.vlan.stats $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 $esxcli.network.port.filter $esxcli.network.port.filter.stats $esxcli.network.port.filter.stats.get(long portid) $esxcli.network.port.filter.help() $esxcli.network.port.stats $esxcli.network.port.stats.get(long portid) $esxcli.network.port.help() $esxcli.network.sriovnic $esxcli.network.sriovnic.vf $esxcli.network.sriovnic.vf.list(string nicname) $esxcli.network.sriovnic.vf.stats(string nicname, long vfid) $esxcli.network.sriovnic.list() $esxcli.network.vm $esxcli.network.vm.port $esxcli.network.vm.port.list(long worldid) $esxcli.network.vm.list() $esxcli.network.vswitch $esxcli.network.vswitch.dvs $esxcli.network.vswitch.dvs.vmware $esxcli.network.vswitch.dvs.vmware.lacp $esxcli.network.vswitch.dvs.vmware.lacp.config $esxcli.network.vswitch.dvs.vmware.lacp.config.get(string dvs) $esxcli.network.vswitch.dvs.vmware.lacp.stats $esxcli.network.vswitch.dvs.vmware.lacp.stats.get(string dvs) $esxcli.network.vswitch.dvs.vmware.lacp.status $esxcli.network.vswitch.dvs.vmware.lacp.status.get(string dvs) $esxcli.network.vswitch.dvs.vmware.lacp.timeout $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.vxlan $esxcli.network.vswitch.dvs.vmware.vxlan.config $esxcli.network.vswitch.dvs.vmware.vxlan.config.stats $esxcli.network.vswitch.dvs.vmware.vxlan.config.stats.get() $esxcli.network.vswitch.dvs.vmware.vxlan.config.stats.set(long level) $esxcli.network.vswitch.dvs.vmware.vxlan.config.help() $esxcli.network.vswitch.dvs.vmware.vxlan.network $esxcli.network.vswitch.dvs.vmware.vxlan.network.arp $esxcli.network.vswitch.dvs.vmware.vxlan.network.arp.list(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.arp.reset(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.mac $esxcli.network.vswitch.dvs.vmware.vxlan.network.mac.list(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.mac.reset(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.mtep $esxcli.network.vswitch.dvs.vmware.vxlan.network.mtep.list(string mtepip, string segmentid, string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.port $esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats $esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats.list(string vdsname, string vdsportid, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats.reset(string vdsname, string vdsportid, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.port.list(string vdsname, string vdsportid, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.stats $esxcli.network.vswitch.dvs.vmware.vxlan.network.stats.list(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.stats.reset(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.network.list(string vdsname, long vxlanid) $esxcli.network.vswitch.dvs.vmware.vxlan.stats $esxcli.network.vswitch.dvs.vmware.vxlan.stats.list(string vdsname) $esxcli.network.vswitch.dvs.vmware.vxlan.stats.reset(string vdsname) $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.multicastgroup $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.multicastgroup.list(string vdsname, long vmknicid, string vmknicip, string vmknicname) $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats.list(long endpointid, string vdsname, string vmknicip, string vmknicname) $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats.reset(long endpointid, string vdsname, string vmknicip, string vmknicname) $esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.list(long endpointid, string vdsname, string vmknicip, string vmknicname) $esxcli.network.vswitch.dvs.vmware.vxlan.get() $esxcli.network.vswitch.dvs.vmware.vxlan.list(string vdsname) $esxcli.network.vswitch.dvs.vmware.list(string vdsname) $esxcli.network.vswitch.dvs.help() $esxcli.network.vswitch.standard $esxcli.network.vswitch.standard.policy $esxcli.network.vswitch.standard.policy.failover $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 $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 $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 $esxcli.network.vswitch.standard.portgroup.policy $esxcli.network.vswitch.standard.portgroup.policy.failover $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 $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 $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 $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.sched $esxcli.sched.reliablemem $esxcli.sched.reliablemem.get() $esxcli.sched.swap $esxcli.sched.swap.system $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 $esxcli.software.acceptance $esxcli.software.acceptance.get() $esxcli.software.acceptance.set(string level) $esxcli.software.profile $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 $esxcli.software.sources.profile $esxcli.software.sources.profile.get(string[] depot, string profile, string proxy) $esxcli.software.sources.profile.list(string[] depot, string proxy) $esxcli.software.sources.vib $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 $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 $esxcli.storage.core $esxcli.storage.core.adapter $esxcli.storage.core.adapter.stats $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 $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 $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) $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 $esxcli.storage.core.device.detached $esxcli.storage.core.device.detached.list(string device) $esxcli.storage.core.device.detached.remove(string device) $esxcli.storage.core.device.partition $esxcli.storage.core.device.partition.list(string device) $esxcli.storage.core.device.partition.showguid(string device) $esxcli.storage.core.device.smart $esxcli.storage.core.device.smart.get(string devicename) $esxcli.storage.core.device.stats $esxcli.storage.core.device.stats.get(string device) $esxcli.storage.core.device.vaai $esxcli.storage.core.device.vaai.status $esxcli.storage.core.device.vaai.status.get(string device) $esxcli.storage.core.device.vaai.help() $esxcli.storage.core.device.world $esxcli.storage.core.device.world.list(string device) $esxcli.storage.core.device.list(string device) $esxcli.storage.core.device.set(boolean defaultname, string device, string name, boolean nopersist, long queuefullsamplesize, long queuefullthreshold, long schednumreqoutstanding, string state) $esxcli.storage.core.device.setconfig(boolean detached, string device, boolean perenniallyreserved) $esxcli.storage.core.path $esxcli.storage.core.path.stats $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 $esxcli.storage.core.plugin.registration $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 $esxcli.storage.filesystem.automount() $esxcli.storage.filesystem.list() $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 $esxcli.storage.nfs.param $esxcli.storage.nfs.param.get(string volumename) $esxcli.storage.nfs.param.set(long maxqueuedepth, string volumename) $esxcli.storage.nfs.add(string host, boolean readonly, string share, string volumename) $esxcli.storage.nfs.list() $esxcli.storage.nfs.remove(string volumename) $esxcli.storage.nmp $esxcli.storage.nmp.device $esxcli.storage.nmp.device.list(string device) $esxcli.storage.nmp.device.set(boolean default, string device, string psp) $esxcli.storage.nmp.path $esxcli.storage.nmp.path.list(string device, string path) $esxcli.storage.nmp.psp $esxcli.storage.nmp.psp.fixed $esxcli.storage.nmp.psp.fixed.deviceconfig $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 $esxcli.storage.nmp.psp.generic.deviceconfig $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 $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 $esxcli.storage.nmp.psp.roundrobin.deviceconfig $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 $esxcli.storage.nmp.satp.generic $esxcli.storage.nmp.satp.generic.deviceconfig $esxcli.storage.nmp.satp.generic.deviceconfig.get(string device) $esxcli.storage.nmp.satp.generic.deviceconfig.set(string config, string device) $esxcli.storage.nmp.satp.generic.pathconfig $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 $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 $esxcli.storage.san.fc $esxcli.storage.san.fc.events $esxcli.storage.san.fc.events.clear(string adapter) $esxcli.storage.san.fc.events.get(string adapter) $esxcli.storage.san.fc.stats $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 $esxcli.storage.san.fcoe.stats $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 $esxcli.storage.san.iscsi.stats $esxcli.storage.san.iscsi.stats.get(string adapter) $esxcli.storage.san.iscsi.list(string adapter) $esxcli.storage.san.sas $esxcli.storage.san.sas.stats $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 $esxcli.storage.vflash.cache $esxcli.storage.vflash.cache.stats $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 $esxcli.storage.vflash.device.list(boolean eligible, boolean used) $esxcli.storage.vflash.module $esxcli.storage.vflash.module.stats $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 $esxcli.storage.vmfs.extent $esxcli.storage.vmfs.extent.list() $esxcli.storage.vmfs.snapshot $esxcli.storage.vmfs.snapshot.extent $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.system $esxcli.system.boot $esxcli.system.boot.device $esxcli.system.boot.device.get() $esxcli.system.boot.help() $esxcli.system.coredump $esxcli.system.coredump.file $esxcli.system.coredump.file.add(boolean auto, string datastore, 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 $esxcli.system.coredump.network.check() $esxcli.system.coredump.network.get() $esxcli.system.coredump.network.set(boolean enable, string interfacename, string serveripv4, long serverport) $esxcli.system.coredump.partition $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 $esxcli.system.hostname.get() $esxcli.system.hostname.set(string domain, string fqdn, string host) $esxcli.system.maintenanceMode $esxcli.system.maintenanceMode.get() $esxcli.system.maintenanceMode.set(boolean enable, long timeout) $esxcli.system.module $esxcli.system.module.parameters $esxcli.system.module.parameters.list(string module) $esxcli.system.module.parameters.set(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.process $esxcli.system.process.stats $esxcli.system.process.stats.load $esxcli.system.process.stats.load.get() $esxcli.system.process.stats.running $esxcli.system.process.stats.running.get() $esxcli.system.process.stats.help() $esxcli.system.process.list() $esxcli.system.secpolicy $esxcli.system.secpolicy.domain $esxcli.system.secpolicy.domain.list() $esxcli.system.secpolicy.domain.set(boolean alldomains, string level, string name) $esxcli.system.secpolicy.help() $esxcli.system.security $esxcli.system.security.certificatestore $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 $esxcli.system.settings.advanced $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 $esxcli.system.settings.kernel.list(boolean delta, string option) $esxcli.system.settings.kernel.set(string setting, string value) $esxcli.system.settings.keyboard $esxcli.system.settings.keyboard.layout $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 $esxcli.system.shutdown.poweroff(long delay, string reason) $esxcli.system.shutdown.reboot(long delay, string reason) $esxcli.system.snmp $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, 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 $esxcli.system.stats.uptime $esxcli.system.stats.uptime.get() $esxcli.system.stats.help() $esxcli.system.syslog $esxcli.system.syslog.config $esxcli.system.syslog.config.logger $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(long defaultrotate, long defaultsize, long defaulttimeout, string logdir, boolean logdirunique, string loghost, string reset) $esxcli.system.syslog.mark(string message) $esxcli.system.syslog.reload() $esxcli.system.time $esxcli.system.time.get() $esxcli.system.time.set(long day, long hour, long min, long month, long sec, long year) $esxcli.system.uuid $esxcli.system.uuid.get() $esxcli.system.version $esxcli.system.version.get() $esxcli.system.visorfs $esxcli.system.visorfs.ramdisk $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 $esxcli.system.visorfs.tardisk.list() $esxcli.system.visorfs.get() $esxcli.system.welcomemsg $esxcli.system.welcomemsg.get() $esxcli.system.welcomemsg.set(string message) $esxcli.vm $esxcli.vm.process $esxcli.vm.process.kill(string type, long worldid) $esxcli.vm.process.list() $esxcli.vsan $esxcli.vsan.cluster $esxcli.vsan.cluster.get() $esxcli.vsan.cluster.join(string clusteruuid, boolean wait) $esxcli.vsan.cluster.leave() $esxcli.vsan.cluster.restore() $esxcli.vsan.datastore $esxcli.vsan.datastore.name $esxcli.vsan.datastore.name.get() $esxcli.vsan.datastore.name.set(string newname) $esxcli.vsan.datastore.help() $esxcli.vsan.maintenancemode $esxcli.vsan.maintenancemode.cancel() $esxcli.vsan.network $esxcli.vsan.network.ipv4 $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 $esxcli.vsan.policy.cleardefault() $esxcli.vsan.policy.getdefault(string policyclass) $esxcli.vsan.policy.setdefault(string policy, string policyclass) $esxcli.vsan.storage $esxcli.vsan.storage.automode $esxcli.vsan.storage.automode.get() $esxcli.vsan.storage.automode.set(boolean enabled) $esxcli.vsan.storage.add(string[] disks, string ssd) $esxcli.vsan.storage.list(string device) $esxcli.vsan.storage.remove(string disk, string ssd, string uuid) $esxcli.vsan.trace $esxcli.vsan.trace.set(long numfiles, string path, boolean reset, long size)
:smile: Thanks for the post.
How would you pass command options? For instance, the --vds-name=dvs1 part of this command:
~ # esxcli network vswitch dvs vmware vxlan vmknic list --vds-name=dvs1
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.list($null, "dvs1", $null, $null)
Hello and thank you for this information!
I am having trouble with the Output for the following command.
$esxcli.network.firewall.get()
I get the following:
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $esxcli.network.firewall.get()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Any ideas?
Hi,
THX for the post.
How would you pass the command :
esxcli storage core device detached remove -d naa.ID
The command is: $esxcli.storage.core.device.detached.remove(string device)
should work with $esxcli.storage.core.device.detached.remove("naa.ID")
couldn't test it out...
I already test the command and is not ok :sad:
Error message (in french sorry):
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>
storage.core.device.detached.remove("naa.60050768028283bf400000000000004
Message: Un paramètre spécifié était incorrect.
argument[0];
InnerText: argument[0]
Au niveau de ligne : 1 Caractère : 44
+ $esxcli.storage.core.device.detached.remove <<<< ("naa.60050768028283b
0000000045")
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodInvocationException
Pingback: HowTo use ESXCLI in PowerCLI | Mingle Mangle of my Mind
Pingback: Get-EsxCli on steroids | The Crazy Consultant
Fantastic
Pingback: PowerCLI for Host Storage | Another vSphere Blog
Dear, fgrehl,
I tried to remove the luns from host ahter detaching it.
the command was not successful.got below error.
PowerCLI C:\> $esxcli.storage.core.device.detached.remove($naa)
Message: A specified parameter was not correct.
argument[0];
InnerText: argument[0]
At line:1 char:1
+ $dc1nix3p015.storage.core.device.detached.remove("naa.60060e8007dd6c000030dd6c00009122")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidArgument
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument
Can you please help me,ane let me know how to pause the device Naa value to the command to get it work.
Thank you in advance
really Interesting post!
But i'm stuck....
You write :
$esxcli.system.settings.advanced.set(boolean default, long intvalue, string option, string stringvalue)
So I've tried
$esxcli.system.settings.advanced.set($False,"/Net/CoalesceRBCRate"
,IntValue,16000) to set IntValue to 16000 (default 4000) and I got an error :(
Any idea?
Try to use the -v2 option, which is way more intuitive.
I've explained the new -v2 option here.
Thanks for your Answer!
I've found the solution before your comment!
I've used the new powercli Get-AdvancedSetting/Set-AdvancedSetting that's really rocks and I loved it!
I will give a try to -V2 option because it seems to be a little bit verbose.
really apreciate your help!
Regards,
Jacques
I am trying to use the following as a powercli command:
esxcli storeage vmfs unmap -l "datastorename"
everything I try results in an error, either a "unexpected token" or "does not contain a method named 'unmap'"
i got the same problem,
Is there a solution for this??
Please try to use ESXLI v2, which is explained here: http://www.virten.net/2016/11/how-to-use-esxcli-v2-commands-in-powercli/
v2 is much more intuitive to use.
Thank you for this post!! It helped me out a lot. I am using this method to script something, and I've run into a wall.
So, from PowerCLI, I have:
$targets = ('esx01','esx02','esx03') #there are > 75 hosts, each has a coredump
#so...to remove the dumpfiles, which MUST be removed from each ESXi host where
#the dumpfile resides
foreach ($bullseye in $targets) {
$esxcli = Get-EsxCli -VMhost $bullseye
$esxcli.system.coredump.file.remove.force
}
#No workie. Anything pop out at you that I'm doing wrong here?