Skip to content

How to use ESXCLI v2 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. A 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 with the new V2 interface, which is much more intuitive than the old method.

get-esxcli

Getting Started with Get-ESXCli -V2

First of all, grab the latest version of vSphere PowerCLI. You can always find a link to the latest version at my VMware Product Latest Version page. You should at least use PowerCLI 6.5 Release 1 [Download]. PowerCLI cmdlets are backward compatible, so you dont need vSphere 6.5 to use the latest release.

Connect to a vCenter Server or an ESXi Host directly and use the Get-EsxCli cmdlet to create the object that you can run commands against. Make sure to add the -V2 parameter to use new interface.

Connect-VIServer vc.virten.lab -User "admin" -Password "vmware"
$esxcli = Get-EsxCli -VMhost esx1.virten.lab -V2

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: esx1.virten.lab

   Elements:
   ---------
   device
   elxnet
   esxcli
   fcoe
   graphics
   hardware
   iscsi
   network
   nvme
   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.network

======================
EsxCliElement: network

   Elements:
   ---------
   diag
   firewall
   ip
   multicast
   nic
   port
   sriovnic
   vm
   vswitch


   Methods:
   --------
   string Help()

At some point "Method Elements" show up:

PS C:\> $esxcli.network.nic

==================
EsxCliElement: nic

   Elements:
   ---------
   coalesce
   cso
   eeprom
   negotiate
   pauseParams
   queue
   register
   ring
   selftest
   sg
   software
   stats
   tso
   vlan


   Method Elements:
   ---------
   down
   get
   list
   set
   up


   Methods:
   --------
   string Help()

The behavior to run a command has been changed with the new Get-EsxCli V2 interface. Instead of using $esxcli.network.nic.list() you have to use $esxcli.network.nic.list.Invoke().

PS C:\> $esxcli.network.nic.list.Invoke()

AdminStatus : Up
Description : Intel Corporation Ethernet Connection (2) I219-V
Driver      : ne1000
Duplex      : Full
Link        : Up
LinkStatus  : Up
MACAddress  : 00:1f:c6:9b:96:59
MTU         : 1500
Name        : vmnic0
PCIDevice   : 0000:00:1f.6
Speed       : 1000

The major change in Get-EsxCli V2 is the behavior when running commands with parameters. Instead of listing all parameters in the required sequence, you can now specify parameters by their name. To list available parameter you can either call CreateArgs() or the Help() function.

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

Name        Value 
----        ----- 
type        Unset, ([string]) 
worldid     Unset, ([long])

 C:\> $esxcli.vm.process.kill.Help()

=======================================================================================================================
vim.EsxCLI.vm.process.kill
-----------------------------------------------------------------------------------------------------------------------
Used to forcibly kill Virtual Machines that are stuck and not responding to normal stop operations.

Param
-----------------------------------------------------------------------------------------------------------------------
- type      | The type of kill operation to attempt. There are three types of VM kills that can be attempted: 
            | [soft, hard, force]. Users should always attempt 'soft' kills first, which will give the VMX p
            | rocess a chance to shutdown cleanly (like kill or kill -SIGTERM). If that does not work move to 
            | 'hard' kills which will shutdown the process immediately (like kill -9 or kill -SIGKILL). 'force
            | ' should be used as a last resort attempt to kill the VM. If all three fail then a reboot is req
            | uired. 

- world-id  | The World ID of the Virtual Machine to kill. This can be obtained from the 'vm process list' com
            | mand 

Be aware that the Help() function may display parameters containing hyphens, which does not work when running the command. Just omit hyphens when setting the parameter as correctly shown by CreateArgs().

Use the Invoke() method and pass parameters as a hashtable to run the command:

PS C:\> $esxcli.vm.process.kill.Invoke(@{type = 'hard'; worldid = '2251094'})
true

Alternatively you can use a helper object to pass parameters:

PS C:\> $esxcli = Get-ESXCLI -VMHost (Get-VMhost esx4.virten.lab) -V2
PS C:\> $arguments = $esxcli.network.diag.ping.CreateArgs()
PS C:\> $arguments
Name                           Value 
----                           -----      
host                           Unset, ([string], optional) 
wait                           Unset, ([string], optional) 
df                             Unset, ([boolean], optional)
interval                       Unset, ([string], optional)
ttl                            Unset, ([long], optional) 
debug                          Unset, ([boolean], optional)
nexthop                        Unset, ([string], optional)
count                          Unset, ([long], optional)  
netstack                       Unset, ([string], optional) 
size                           Unset, ([long], optional)  
ipv4                           Unset, ([boolean], optional) 
ipv6                           Unset, ([boolean], optional)
interface                      Unset, ([string], optional) 
PS C:\> $arguments.count = 2
PS C:\> $arguments.host = “192.168.0.1”
PS C:\> $arguments
Name                           Value
----                           -----   
host                           192.168.222.250   
wait                           Unset, ([string], optional)  
df                             Unset, ([boolean], optional) 
interval                       Unset, ([string], optional)  
ttl                            Unset, ([long], optional)    
debug                          Unset, ([boolean], optional)   
nexthop                        Unset, ([string], optional)  
count                          2   
netstack                       Unset, ([string], optional)    
size                           Unset, ([long], optional)    
ipv4                           Unset, ([boolean], optional)
ipv6                           Unset, ([boolean], optional)
interface                      Unset, ([string], optional)  

PS C:\> $esxcli.network.diag.ping.Invoke($arguments)

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

$EsxHosts = Get-VMHost
foreach($EsxHost in $EsxHosts){
  $esxcli = Get-VMHost $EsxHost | Get-EsxCli -V2
  $esxcli.vm.process.list.Invoke()
}

 

The following table displays all commands with their paramters. available in ESXi 6.5.

CommandParameter
CommandParameter
$esxcli.device.adddeviceidentifier
instanceaddress
$esxcli.device.alias.getalias
$esxcli.device.alias.list
$esxcli.device.driver.listdevices
$esxcli.elxnet.dbgmask.getpcidevname
$esxcli.elxnet.dbgmask.setmask
pcidevname
$esxcli.elxnet.regdump.getfilepath
pcidevname
$esxcli.elxnet.stats.getpcidevname
$esxcli.elxnet.vib.get
$esxcli.esxcli.command.list
$esxcli.fcoe.adapter.list
$esxcli.fcoe.adapter.removeadaptername
$esxcli.fcoe.nic.disablenicname
$esxcli.fcoe.nic.discovernicname
$esxcli.fcoe.nic.enablenicname
$esxcli.fcoe.nic.list
$esxcli.fcoe.nic.removenicname
$esxcli.fcoe.nic.setenablevn2vn
nicname
priority
vlanid
$esxcli.graphics.device.list
$esxcli.graphics.device.stats.list
$esxcli.graphics.host.get
$esxcli.graphics.host.refresh
$esxcli.graphics.host.setdefaulttype
sharedpassthruassignmentpolicy
$esxcli.graphics.vm.list
$esxcli.hardware.bootdevice.list
$esxcli.hardware.clock.get
$esxcli.hardware.clock.setday
hour
min
month
sec
year
$esxcli.hardware.cpu.cpuid.getcpu
$esxcli.hardware.cpu.global.get
$esxcli.hardware.cpu.global.sethyperthreading
$esxcli.hardware.cpu.list
$esxcli.hardware.ipmi.fru.getignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.fru.listignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.sdr.getignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.sdr.listformatter
ignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.sel.clearignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.sel.getignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.ipmi.sel.listignoremissing
includeprettyraw
includeraw
node
$esxcli.hardware.memory.get
$esxcli.hardware.pci.listclass
mask
$esxcli.hardware.platform.get
$esxcli.hardware.smartcard.certificate.listslot
$esxcli.hardware.smartcard.info.get
$esxcli.hardware.smartcard.slot.list
$esxcli.hardware.smartcard.token.listslot
$esxcli.hardware.trustedboot.get
$esxcli.hardware.usb.passthrough.device.disabledevice
$esxcli.hardware.usb.passthrough.device.enabledevice
$esxcli.hardware.usb.passthrough.device.list
$esxcli.iscsi.adapter.auth.chap.getadapter
direction
$esxcli.iscsi.adapter.auth.chap.setadapter
authname
default
direction
level
secret
$esxcli.iscsi.adapter.capabilities.getadapter
$esxcli.iscsi.adapter.discovery.rediscoveradapter
$esxcli.iscsi.adapter.discovery.sendtarget.addadapter
address
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.getadapter
address
direction
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.setadapter
address
authname
default
direction
inherit
level
secret
$esxcli.iscsi.adapter.discovery.sendtarget.listadapter
$esxcli.iscsi.adapter.discovery.sendtarget.param.getadapter
address
$esxcli.iscsi.adapter.discovery.sendtarget.param.setadapter
address
default
inherit
key
value
$esxcli.iscsi.adapter.discovery.sendtarget.removeadapter
address
$esxcli.iscsi.adapter.discovery.statictarget.addadapter
address
name
$esxcli.iscsi.adapter.discovery.statictarget.listadapter
$esxcli.iscsi.adapter.discovery.statictarget.removeadapter
address
name
$esxcli.iscsi.adapter.discovery.status.getadapter
$esxcli.iscsi.adapter.firmware.getadapter
file
$esxcli.iscsi.adapter.firmware.setadapter
file
$esxcli.iscsi.adapter.getadapter
$esxcli.iscsi.adapter.listadapter
$esxcli.iscsi.adapter.param.getadapter
$esxcli.iscsi.adapter.param.setadapter
default
key
value
$esxcli.iscsi.adapter.setadapter
alias
name
skipifsessionactive
$esxcli.iscsi.adapter.target.listadapter
name
$esxcli.iscsi.adapter.target.portal.auth.chap.getadapter
address
direction
method
name
$esxcli.iscsi.adapter.target.portal.auth.chap.setadapter
address
authname
default
direction
inherit
level
name
secret
$esxcli.iscsi.adapter.target.portal.listadapter
name
$esxcli.iscsi.adapter.target.portal.param.getadapter
address
name
$esxcli.iscsi.adapter.target.portal.param.setadapter
address
default
inherit
key
name
value
$esxcli.iscsi.ibftboot.get
$esxcli.iscsi.ibftboot.import
$esxcli.iscsi.logicalnetworkportal.listadapter
$esxcli.iscsi.networkportal.addadapter
force
nic
$esxcli.iscsi.networkportal.ipconfig.getadapter
nic
$esxcli.iscsi.networkportal.ipconfig.setadapter
dns1
dns2
enable
enabledhcpv4
gateway
ip
nic
subnet
$esxcli.iscsi.networkportal.ipv6config.address.addadapter
addresslist
removeallexisting
$esxcli.iscsi.networkportal.ipv6config.address.listadapter
$esxcli.iscsi.networkportal.ipv6config.address.removeadapter
addresslist
$esxcli.iscsi.networkportal.ipv6config.getadapter
$esxcli.iscsi.networkportal.ipv6config.setadapter
enable
enabledhcpv6
enablelinklocalautoconfiguration
enablerouteradvertisement
gateway6
$esxcli.iscsi.networkportal.listadapter
$esxcli.iscsi.networkportal.removeadapter
force
nic
$esxcli.iscsi.physicalnetworkportal.listadapter
$esxcli.iscsi.physicalnetworkportal.param.getadapter
nic
$esxcli.iscsi.physicalnetworkportal.param.setadapter
nic
option
value
$esxcli.iscsi.plugin.listadapter
plugin
$esxcli.iscsi.session.addadapter
isid
name
$esxcli.iscsi.session.connection.listadapter
cid
isid
name
$esxcli.iscsi.session.listadapter
isid
name
$esxcli.iscsi.session.removeadapter
isid
name
$esxcli.iscsi.software.get
$esxcli.iscsi.software.setenabled
name
$esxcli.network.diag.pingcount
debug
df
host
interface
interval
ipv4
ipv6
netstack
nexthop
size
ttl
wait
$esxcli.network.firewall.get
$esxcli.network.firewall.load
$esxcli.network.firewall.refresh
$esxcli.network.firewall.ruleset.allowedip.addipaddress
rulesetid
$esxcli.network.firewall.ruleset.allowedip.listrulesetid
$esxcli.network.firewall.ruleset.allowedip.removeipaddress
rulesetid
$esxcli.network.firewall.ruleset.listrulesetid
$esxcli.network.firewall.ruleset.rule.listrulesetid
$esxcli.network.firewall.ruleset.setallowedall
enabled
rulesetid
$esxcli.network.firewall.setdefaultaction
enabled
$esxcli.network.firewall.unload
$esxcli.network.ip.connection.listnetstack
type
$esxcli.network.ip.dns.search.adddomain
netstack
$esxcli.network.ip.dns.search.listnetstack
$esxcli.network.ip.dns.search.removedomain
netstack
$esxcli.network.ip.dns.server.addnetstack
server
$esxcli.network.ip.dns.server.listnetstack
$esxcli.network.ip.dns.server.removeall
netstack
server
$esxcli.network.ip.get
$esxcli.network.ip.interface.adddvportid
dvsname
interfacename
macaddress
mtu
netstack
portgroupname
$esxcli.network.ip.interface.ipv4.address.listinterfacename
netstack
$esxcli.network.ip.interface.ipv4.getinterfacename
netstack
$esxcli.network.ip.interface.ipv4.setgateway
interfacename
ipv4
netmask
peerdns
type
$esxcli.network.ip.interface.ipv6.address.addinterfacename
ipv6
$esxcli.network.ip.interface.ipv6.address.listinterfacename
$esxcli.network.ip.interface.ipv6.address.removeinterfacename
ipv6
$esxcli.network.ip.interface.ipv6.getinterfacename
netstack
$esxcli.network.ip.interface.ipv6.setenabledhcpv6
enableipv6
enablerouteradv
gateway
interfacename
peerdns
$esxcli.network.ip.interface.listnetstack
$esxcli.network.ip.interface.removedvportid
dvsname
interfacename
netstack
portgroupname
$esxcli.network.ip.interface.setenabled
interfacename
mtu
$esxcli.network.ip.interface.tag.addinterfacename
tagname
$esxcli.network.ip.interface.tag.getinterfacename
$esxcli.network.ip.interface.tag.removeinterfacename
tagname
$esxcli.network.ip.ipsec.sa.addencryptionalgorithm
encryptionkey
integrityalgorithm
integritykey
sadestination
samode
saname
sasource
saspi
$esxcli.network.ip.ipsec.sa.list
$esxcli.network.ip.ipsec.sa.removeremoveall
sadestination
saname
sasource
saspi
$esxcli.network.ip.ipsec.sp.addaction
destinationport
flowdirection
saname
sourceport
spdestination
spmode
spname
spsource
upperlayerprotocol
$esxcli.network.ip.ipsec.sp.list
$esxcli.network.ip.ipsec.sp.removeremoveall
spname
$esxcli.network.ip.neighbor.listinterfacename
netstack
version
$esxcli.network.ip.neighbor.removeinterfacename
neighboraddr
netstack
version
$esxcli.network.ip.netstack.adddisabled
netstack
$esxcli.network.ip.netstack.getnetstack
$esxcli.network.ip.netstack.list
$esxcli.network.ip.netstack.removenetstack
$esxcli.network.ip.netstack.setccalgo
enable
ipv6enabled
maxconn
name
netstack
$esxcli.network.ip.route.ipv4.addgateway
netstack
network
$esxcli.network.ip.route.ipv4.listnetstack
$esxcli.network.ip.route.ipv4.removegateway
netstack
network
$esxcli.network.ip.route.ipv6.addgateway
netstack
network
$esxcli.network.ip.route.ipv6.listnetstack
$esxcli.network.ip.route.ipv6.removegateway
netstack
network
$esxcli.network.ip.setipv6enabled
$esxcli.network.multicast.group.list
$esxcli.network.nic.coalesce.getvmnic
$esxcli.network.nic.coalesce.high.getvmnic
$esxcli.network.nic.coalesce.high.setpktrate
rxmaxframes
rxusecs
txmaxframes
txusecs
vmnic
$esxcli.network.nic.coalesce.low.getvmnic
$esxcli.network.nic.coalesce.low.setpktrate
rxmaxframes
rxusecs
txmaxframes
txusecs
vmnic
$esxcli.network.nic.coalesce.setadaptiverx
adaptivetx
rxmaxframes
rxusecs
sampleinterval
txmaxframes
txusecs
vmnic
$esxcli.network.nic.cso.getvmnic
$esxcli.network.nic.cso.setenable
vmnic
$esxcli.network.nic.downnicname
$esxcli.network.nic.eeprom.changefile
magic
offset
value
vmnic
$esxcli.network.nic.eeprom.dumplength
offset
vmnic
$esxcli.network.nic.getnicname
$esxcli.network.nic.list
$esxcli.network.nic.negotiate.restartvmnic
$esxcli.network.nic.pauseParams.listnicname
$esxcli.network.nic.pauseParams.setauto
nicname
rx
tx
$esxcli.network.nic.queue.count.getvmnic
$esxcli.network.nic.queue.count.setnum
rx
tx
vmnic
$esxcli.network.nic.queue.filterclass.list
$esxcli.network.nic.queue.loadbalancer.list
$esxcli.network.nic.queue.loadbalancer.setdynpoollb
geneveoamlb
lrolb
numadynlb
rsslb
rxdynlb
rxqlatency
rxqnofeat
rxqpair
rxqpreempt
vmnic
$esxcli.network.nic.register.dumpvmnic
$esxcli.network.nic.ring.current.getnicname
$esxcli.network.nic.ring.current.setnicname
rx
rxjumbo
rxmini
tx
$esxcli.network.nic.ring.preset.getnicname
$esxcli.network.nic.selftest.runonline
vmnic
$esxcli.network.nic.setauto
duplex
messagelevel
nicname
phyaddress
port
speed
transceivertype
virtualaddress
wakeonlan
$esxcli.network.nic.sg.getvmnic
$esxcli.network.nic.sg.setenable
vmnic
$esxcli.network.nic.software.list
$esxcli.network.nic.software.setgeneveoffload
highdma
ipv4cso
ipv4tso
ipv6cso
ipv6csoext
ipv6tso
ipv6tsoext
obo
sg
sgsp
tagging
untagging
vmnic
vxlanencap
$esxcli.network.nic.stats.getnicname
$esxcli.network.nic.tso.getvmnic
$esxcli.network.nic.tso.setenable
vmnic
$esxcli.network.nic.upnicname
$esxcli.network.nic.vlan.stats.getnicname
$esxcli.network.nic.vlan.stats.setenabled
nicname
$esxcli.network.port.filter.stats.getportid
$esxcli.network.port.stats.getportid
$esxcli.network.sriovnic.list
$esxcli.network.sriovnic.vf.listnicname
$esxcli.network.sriovnic.vf.statsnicname
vfid
$esxcli.network.vm.list
$esxcli.network.vm.port.listworldid
$esxcli.network.vswitch.dvs.vmware.lacp.config.getdvs
$esxcli.network.vswitch.dvs.vmware.lacp.stats.getdvs
$esxcli.network.vswitch.dvs.vmware.lacp.status.getdvs
$esxcli.network.vswitch.dvs.vmware.lacp.timeout.setlagid
nicname
timeout
vds
$esxcli.network.vswitch.dvs.vmware.listvdsname
$esxcli.network.vswitch.standard.addports
vswitchname
$esxcli.network.vswitch.standard.listvswitchname
$esxcli.network.vswitch.standard.policy.failover.getvswitchname
$esxcli.network.vswitch.standard.policy.failover.setactiveuplinks
failback
failuredetection
loadbalancing
notifyswitches
standbyuplinks
vswitchname
$esxcli.network.vswitch.standard.policy.security.getvswitchname
$esxcli.network.vswitch.standard.policy.security.setallowforgedtransmits
allowmacchange
allowpromiscuous
vswitchname
$esxcli.network.vswitch.standard.policy.shaping.getvswitchname
$esxcli.network.vswitch.standard.policy.shaping.setavgbandwidth
burstsize
enabled
peakbandwidth
vswitchname
$esxcli.network.vswitch.standard.portgroup.addportgroupname
vswitchname
$esxcli.network.vswitch.standard.portgroup.list
$esxcli.network.vswitch.standard.portgroup.policy.failover.getportgroupname
$esxcli.network.vswitch.standard.portgroup.policy.failover.setactiveuplinks
failback
failuredetection
loadbalancing
notifyswitches
portgroupname
standbyuplinks
usevswitch
$esxcli.network.vswitch.standard.portgroup.policy.security.getportgroupname
$esxcli.network.vswitch.standard.portgroup.policy.security.setallowforgedtransmits
allowmacchange
allowpromiscuous
portgroupname
usevswitch
$esxcli.network.vswitch.standard.portgroup.policy.shaping.getportgroupname
$esxcli.network.vswitch.standard.portgroup.policy.shaping.setavgbandwidth
burstsize
enabled
peakbandwidth
portgroupname
usevswitch
$esxcli.network.vswitch.standard.portgroup.removeportgroupname
vswitchname
$esxcli.network.vswitch.standard.portgroup.setportgroupname
vlanid
$esxcli.network.vswitch.standard.removevswitchname
$esxcli.network.vswitch.standard.setcdpstatus
mtu
vswitchname
$esxcli.network.vswitch.standard.uplink.adduplinkname
vswitchname
$esxcli.network.vswitch.standard.uplink.removeuplinkname
vswitchname
$esxcli.nvme.device.feature.aec.getadapter
$esxcli.nvme.device.feature.aec.setadapter
value
$esxcli.nvme.device.feature.ar.getadapter
$esxcli.nvme.device.feature.ar.setadapter
value
value2
value3
value4
$esxcli.nvme.device.feature.er.getadapter
$esxcli.nvme.device.feature.er.setadapter
value
$esxcli.nvme.device.feature.ic.getadapter
$esxcli.nvme.device.feature.ic.setadapter
value
value2
$esxcli.nvme.device.feature.ivc.getadapter
$esxcli.nvme.device.feature.ivc.setadapter
value
value2
$esxcli.nvme.device.feature.nq.getadapter
$esxcli.nvme.device.feature.pm.getadapter
$esxcli.nvme.device.feature.pm.setadapter
value
$esxcli.nvme.device.feature.tt.getadapter
$esxcli.nvme.device.feature.tt.setadapter
value
$esxcli.nvme.device.feature.vwc.getadapter
$esxcli.nvme.device.feature.vwc.setadapter
value
$esxcli.nvme.device.feature.wa.getadapter
$esxcli.nvme.device.feature.wa.setadapter
value
$esxcli.nvme.device.firmware.activateadapter
slot
$esxcli.nvme.device.firmware.downloadadapter
firmware
slot
$esxcli.nvme.device.getadapter
$esxcli.nvme.device.list
$esxcli.nvme.device.log.error.getadapter
elpe
$esxcli.nvme.device.log.fwslot.getadapter
$esxcli.nvme.device.log.smart.getadapter
namespace
$esxcli.nvme.device.namespace.formatadapter
format
ms
namespace
pi
pil
ses
$esxcli.nvme.device.namespace.getadapter
namespace
$esxcli.nvme.device.namespace.listadapter
$esxcli.nvme.driver.loglevel.setdebuglevel
loglevel
$esxcli.rdma.device.list
$esxcli.rdma.device.stats.getdevice
$esxcli.rdma.device.vmknic.listdevice
$esxcli.rdma.iser.add
$esxcli.sched.reliablemem.get
$esxcli.sched.swap.system.get
$esxcli.sched.swap.system.setdatastoreenabled
datastorename
datastoreorder
hostcacheenabled
hostcacheorder
hostlocalswapenabled
hostlocalswaporder
$esxcli.software.acceptance.get
$esxcli.software.acceptance.setlevel
$esxcli.software.profile.getrebootingimage
$esxcli.software.profile.installdepot
dryrun
force
maintenancemode
noliveinstall
nosigcheck
oktoremove
profile
proxy
$esxcli.software.profile.updateallowdowngrades
depot
dryrun
force
maintenancemode
noliveinstall
nosigcheck
profile
proxy
$esxcli.software.profile.validatedepot
profile
proxy
$esxcli.software.sources.profile.getdepot
profile
proxy
$esxcli.software.sources.profile.listdepot
proxy
$esxcli.software.sources.vib.getdepot
proxy
vibname
viburl
$esxcli.software.sources.vib.listdepot
proxy
$esxcli.software.vib.getrebootingimage
vibname
$esxcli.software.vib.installdepot
dryrun
force
maintenancemode
noliveinstall
nosigcheck
proxy
vibname
viburl
$esxcli.software.vib.listrebootingimage
$esxcli.software.vib.removedryrun
force
maintenancemode
noliveinstall
vibname
$esxcli.software.vib.signature.verify
$esxcli.software.vib.updatedepot
dryrun
force
maintenancemode
noliveinstall
nosigcheck
proxy
vibname
viburl
$esxcli.storage.core.adapter.capabilities.listadapter
$esxcli.storage.core.adapter.list
$esxcli.storage.core.adapter.rescanadapter
all
skipclaim
skipfsscan
type
$esxcli.storage.core.adapter.stats.getadapter
$esxcli.storage.core.claiming.autoclaimclaimruleclass
enabled
wait
$esxcli.storage.core.claiming.reclaimdevice
$esxcli.storage.core.claiming.unclaimadapter
channel
claimruleclass
device
driver
lun
model
path
plugin
target
type
vendor
$esxcli.storage.core.claimrule.addadapter
autoassign
channel
claimruleclass
device
driver
force
forcereserved
ifunset
iqn
lun
model
plugin
rule
target
transport
type
vendor
wwnn
wwpn
xcopymaxtransfersize
xcopyusearrayvalues
xcopyusemultisegs
$esxcli.storage.core.claimrule.convertcommit
$esxcli.storage.core.claimrule.listclaimruleclass
$esxcli.storage.core.claimrule.loadclaimruleclass
$esxcli.storage.core.claimrule.moveclaimruleclass
forcereserved
newrule
rule
$esxcli.storage.core.claimrule.removeclaimruleclass
plugin
rule
$esxcli.storage.core.claimrule.runadapter
channel
claimruleclass
device
lun
path
target
type
wait
$esxcli.storage.core.device.capacity.listdevice
$esxcli.storage.core.device.detached.listdevice
$esxcli.storage.core.device.detached.removeall
device
$esxcli.storage.core.device.latencythreshold.listdevice
$esxcli.storage.core.device.latencythreshold.setdevice
latencysensitivethreshold
$esxcli.storage.core.device.listdevice
excludeoffline
peonly
$esxcli.storage.core.device.partition.listdevice
$esxcli.storage.core.device.partition.showguiddevice
$esxcli.storage.core.device.physical.getdevice
$esxcli.storage.core.device.purgeinterval
$esxcli.storage.core.device.raid.listdevice
$esxcli.storage.core.device.setdataintegrityenabled
defaultname
device
force
ledduration
ledstate
maxqueuedepth
name
nopersist
queuefullsamplesize
queuefullthreshold
schednumreqoutstanding
state
writecacheenabled
$esxcli.storage.core.device.setconfigdetached
device
perenniallyreserved
sharedclusterwide
$esxcli.storage.core.device.smart.getdevicename
$esxcli.storage.core.device.stats.getdevice
$esxcli.storage.core.device.vaai.status.getdevice
$esxcli.storage.core.device.vaai.status.setats
clone
delete
device
zero
$esxcli.storage.core.device.world.listdevice
$esxcli.storage.core.path.listdevice
path
$esxcli.storage.core.path.setpath
state
$esxcli.storage.core.path.stats.getpath
$esxcli.storage.core.plugin.listpluginclass
$esxcli.storage.core.plugin.registration.adddependencies
fullpath
modulename
pluginclass
pluginname
$esxcli.storage.core.plugin.registration.listmodulename
pluginclass
$esxcli.storage.core.plugin.registration.removemodulename
$esxcli.storage.filesystem.automount
$esxcli.storage.filesystem.listignoreerrors
$esxcli.storage.filesystem.mountnopersist
volumelabel
volumeuuid
$esxcli.storage.filesystem.rescan
$esxcli.storage.filesystem.unmountnopersist
unmountallvmfs
volumelabel
volumepath
volumeuuid
$esxcli.storage.iofilter.enablefilter
$esxcli.storage.iofilter.listfilter
$esxcli.storage.nfs.addhost
ispe
readonly
share
volumename
$esxcli.storage.nfs.listpeonly
$esxcli.storage.nfs.param.getvolumename
$esxcli.storage.nfs.param.setmaxqueuedepth
volumename
$esxcli.storage.nfs.removevolumename
$esxcli.storage.nfs41.addhosts
ispe
readonly
sec
share
volumename
$esxcli.storage.nfs41.listpeonly
$esxcli.storage.nfs41.param.getvolumename
$esxcli.storage.nfs41.param.setmaxqueuedepth
volumename
$esxcli.storage.nfs41.removevolumename
$esxcli.storage.nmp.device.listdevice
$esxcli.storage.nmp.device.setdefault
device
psp
$esxcli.storage.nmp.path.listdevice
path
$esxcli.storage.nmp.psp.fixed.deviceconfig.getdevice
$esxcli.storage.nmp.psp.fixed.deviceconfig.setcfgfile
default
device
path
$esxcli.storage.nmp.psp.generic.deviceconfig.getdevice
$esxcli.storage.nmp.psp.generic.deviceconfig.setcfgfile
config
device
$esxcli.storage.nmp.psp.generic.pathconfig.getpath
$esxcli.storage.nmp.psp.generic.pathconfig.setcfgfile
config
path
$esxcli.storage.nmp.psp.list
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.getdevice
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.setbytes
cfgfile
device
iops
type
useano
$esxcli.storage.nmp.satp.generic.deviceconfig.getdevice
excludetpginfo
$esxcli.storage.nmp.satp.generic.deviceconfig.setconfig
device
$esxcli.storage.nmp.satp.generic.pathconfig.getpath
$esxcli.storage.nmp.satp.generic.pathconfig.setconfig
path
$esxcli.storage.nmp.satp.list
$esxcli.storage.nmp.satp.rule.addboot
claimoption
description
device
driver
force
model
option
psp
pspoption
satp
transport
type
vendor
$esxcli.storage.nmp.satp.rule.listsatp
$esxcli.storage.nmp.satp.rule.removeboot
claimoption
description
device
driver
force
model
option
psp
pspoption
satp
transport
type
vendor
$esxcli.storage.nmp.satp.setboot
defaultpsp
satp
$esxcli.storage.san.fc.events.clearadapter
$esxcli.storage.san.fc.events.getadapter
$esxcli.storage.san.fc.listadapter
$esxcli.storage.san.fc.resetadapter
$esxcli.storage.san.fc.stats.getadapter
$esxcli.storage.san.fcoe.listadapter
$esxcli.storage.san.fcoe.resetadapter
$esxcli.storage.san.fcoe.stats.getadapter
$esxcli.storage.san.iscsi.listadapter
$esxcli.storage.san.iscsi.stats.getadapter
$esxcli.storage.san.sas.listadapter
$esxcli.storage.san.sas.resetadapter
$esxcli.storage.san.sas.stats.getadapter
$esxcli.storage.vflash.cache.getcachename
modulename
$esxcli.storage.vflash.cache.listmodulename
$esxcli.storage.vflash.cache.stats.getcachename
modulename
$esxcli.storage.vflash.cache.stats.resetcachename
modulename
$esxcli.storage.vflash.device.listeligible
used
$esxcli.storage.vflash.module.getmodulename
$esxcli.storage.vflash.module.list
$esxcli.storage.vflash.module.stats.getmodulename
$esxcli.storage.vmfs.extent.list
$esxcli.storage.vmfs.host.listliveness
volumelabel
volumeuuid
$esxcli.storage.vmfs.lockmode.listignoreerrors
volumelabel
volumeuuid
$esxcli.storage.vmfs.lockmode.setats
scsi
volumelabel
volumeuuid
$esxcli.storage.vmfs.pbcache.get
$esxcli.storage.vmfs.pbcache.reset
$esxcli.storage.vmfs.reclaim.config.getvolumelabel
volumeuuid
$esxcli.storage.vmfs.reclaim.config.setreclaimgranularity
reclaimpriority
volumelabel
volumeuuid
$esxcli.storage.vmfs.snapshot.extent.listvolumelabel
volumeuuid
$esxcli.storage.vmfs.snapshot.listvolumelabel
volumeuuid
$esxcli.storage.vmfs.snapshot.mountnopersist
volumelabel
volumeuuid
$esxcli.storage.vmfs.snapshot.resignaturevolumelabel
volumeuuid
$esxcli.storage.vmfs.unmapreclaimunit
volumelabel
volumeuuid
$esxcli.storage.vmfs.upgradevolumelabel
volumeuuid
$esxcli.storage.vvol.daemon.unbindall
$esxcli.storage.vvol.protocolendpoint.listpe
petype
$esxcli.storage.vvol.storagecontainer.abandonedvvol.scanpath
$esxcli.storage.vvol.storagecontainer.list
$esxcli.storage.vvol.vasacontext.get
$esxcli.storage.vvol.vasaprovider.list
$esxcli.system.account.adddescription
id
password
passwordconfirmation
$esxcli.system.account.list
$esxcli.system.account.removeid
$esxcli.system.account.setdescription
id
password
passwordconfirmation
$esxcli.system.boot.device.get
$esxcli.system.coredump.file.addauto
datastore
enable
file
size
$esxcli.system.coredump.file.get
$esxcli.system.coredump.file.list
$esxcli.system.coredump.file.removefile
force
$esxcli.system.coredump.file.setenable
path
smart
unconfigure
$esxcli.system.coredump.network.check
$esxcli.system.coredump.network.get
$esxcli.system.coredump.network.setenable
interfacename
serverip
serveripv4
serverport
$esxcli.system.coredump.partition.get
$esxcli.system.coredump.partition.list
$esxcli.system.coredump.partition.setenable
partition
smart
unconfigure
$esxcli.system.coredump.vsan.addauto
enable
size
$esxcli.system.coredump.vsan.get
$esxcli.system.coredump.vsan.list
$esxcli.system.coredump.vsan.removeforce
uuid
$esxcli.system.coredump.vsan.setenable
smart
unconfigure
uuid
$esxcli.system.hostname.get
$esxcli.system.hostname.setdomain
fqdn
host
$esxcli.system.maintenanceMode.get
$esxcli.system.maintenanceMode.setenable
timeout
vsanmode
$esxcli.system.module.getmodule
$esxcli.system.module.listenabled
loaded
$esxcli.system.module.loadforce
module
$esxcli.system.module.parameters.copyforce
parameterkeys
source
target
$esxcli.system.module.parameters.listmodule
$esxcli.system.module.parameters.setappend
force
module
parameterstring
$esxcli.system.module.setenabled
force
module
$esxcli.system.permission.list
$esxcli.system.permission.setgroup
id
role
$esxcli.system.permission.unsetgroup
id
$esxcli.system.process.list
$esxcli.system.process.stats.load.get
$esxcli.system.process.stats.running.get
$esxcli.system.secpolicy.domain.list
$esxcli.system.secpolicy.domain.setalldomains
level
name
$esxcli.system.security.certificatestore.addfilename
$esxcli.system.security.certificatestore.list
$esxcli.system.security.certificatestore.removeissuer
serial
$esxcli.system.settings.advanced.listdelta
option
tree
$esxcli.system.settings.advanced.setdefault
intvalue
option
stringvalue
$esxcli.system.settings.kernel.listdelta
option
$esxcli.system.settings.kernel.setsetting
value
$esxcli.system.settings.keyboard.layout.get
$esxcli.system.settings.keyboard.layout.list
$esxcli.system.settings.keyboard.layout.setlayout
nopersist
$esxcli.system.shutdown.poweroffdelay
reason
$esxcli.system.shutdown.rebootdelay
reason
$esxcli.system.slp.searchnode
port
protocol
service
$esxcli.system.slp.stats.get
$esxcli.system.snmp.get
$esxcli.system.snmp.hashauthhash
privhash
rawsecret
$esxcli.system.snmp.setauthentication
communities
enable
engineid
hwsrc
largestorage
loglevel
notraps
port
privacy
remoteusers
reset
syscontact
syslocation
targets
users
v3targets
$esxcli.system.snmp.testauthhash
privhash
rawsecret
user
$esxcli.system.stats.installtime.get
$esxcli.system.stats.uptime.get
$esxcli.system.syslog.config.get
$esxcli.system.syslog.config.logger.list
$esxcli.system.syslog.config.logger.setid
reset
rotate
size
$esxcli.system.syslog.config.setchecksslcerts
defaultrotate
defaultsize
defaulttimeout
droplogrotate
droplogsize
logdir
logdirunique
loghost
queuedropmark
reset
$esxcli.system.syslog.markmessage
$esxcli.system.syslog.reload
$esxcli.system.time.get
$esxcli.system.time.setday
hour
min
month
sec
year
$esxcli.system.uuid.get
$esxcli.system.version.get
$esxcli.system.visorfs.get
$esxcli.system.visorfs.ramdisk.addmaxsize
minsize
name
permissions
target
$esxcli.system.visorfs.ramdisk.list
$esxcli.system.visorfs.ramdisk.removetarget
$esxcli.system.visorfs.tardisk.list
$esxcli.system.wbem.get
$esxcli.system.wbem.provider.list
$esxcli.system.wbem.provider.setenable
name
$esxcli.system.wbem.setauth
enable
loglevel
port
reset
wsman
$esxcli.system.welcomemsg.get
$esxcli.system.welcomemsg.setmessage
$esxcli.vm.process.killtype
worldid
$esxcli.vm.process.list
$esxcli.vsan.cluster.get
$esxcli.vsan.cluster.joinclusteruuid
wait
witnessnode
witnesspreferredfaultdomain
$esxcli.vsan.cluster.leave
$esxcli.vsan.cluster.new
$esxcli.vsan.cluster.preferredfaultdomain.get
$esxcli.vsan.cluster.preferredfaultdomain.setpreferredfaultdomainname
$esxcli.vsan.cluster.restoreboot
$esxcli.vsan.cluster.unicastagent.addaddr
boundinterfacename
port
$esxcli.vsan.cluster.unicastagent.list
$esxcli.vsan.cluster.unicastagent.removeaddr
port
$esxcli.vsan.datastore.name.get
$esxcli.vsan.datastore.name.setnewname
$esxcli.vsan.faultdomain.get
$esxcli.vsan.faultdomain.reset
$esxcli.vsan.faultdomain.setfdname
$esxcli.vsan.iscsi.defaultconfig.get
$esxcli.vsan.iscsi.defaultconfig.setauthtype
interface
mutualsecret
mutualuserid
port
secret
userid
$esxcli.vsan.iscsi.homeobject.createauthtype
interface
mutualsecret
mutualuserid
policy
port
secret
userid
$esxcli.vsan.iscsi.homeobject.delete
$esxcli.vsan.iscsi.homeobject.get
$esxcli.vsan.iscsi.homeobject.setpolicy
$esxcli.vsan.iscsi.initiatorgroup.addname
$esxcli.vsan.iscsi.initiatorgroup.getname
$esxcli.vsan.iscsi.initiatorgroup.initiator.addgroup
names
$esxcli.vsan.iscsi.initiatorgroup.initiator.removegroup
names
$esxcli.vsan.iscsi.initiatorgroup.list
$esxcli.vsan.iscsi.initiatorgroup.removeforce
name
$esxcli.vsan.iscsi.status.get
$esxcli.vsan.iscsi.status.setenabled
$esxcli.vsan.iscsi.target.addalias
authtype
initiatoradd
interface
iqn
mutualsecret
mutualuserid
policy
port
secret
userid
$esxcli.vsan.iscsi.target.getalias
$esxcli.vsan.iscsi.target.list
$esxcli.vsan.iscsi.target.lun.addalias
id
policy
size
target
$esxcli.vsan.iscsi.target.lun.getid
target
$esxcli.vsan.iscsi.target.lun.listtarget
$esxcli.vsan.iscsi.target.lun.removeid
target
$esxcli.vsan.iscsi.target.lun.setalias
id
newid
policy
size
status
target
$esxcli.vsan.iscsi.target.removealias
$esxcli.vsan.iscsi.target.setalias
authtype
initiatoradd
initiatorremove
interface
mutualsecret
mutualuserid
newalias
policy
port
secret
userid
$esxcli.vsan.maintenancemode.cancel
$esxcli.vsan.network.clear
$esxcli.vsan.network.ip.addagentmcaddr
agentmcport
agentv6mcaddr
hostucport
interfacename
mastermcaddr
mastermcport
masterv6mcaddr
multicastttl
traffictype
$esxcli.vsan.network.ip.removeforce
interfacename
$esxcli.vsan.network.ip.setagentmcaddr
agentmcport
agentv6mcaddr
hostucport
interfacename
mastermcaddr
mastermcport
masterv6mcaddr
multicastttl
traffictype
$esxcli.vsan.network.ipv4.addagentmcaddr
agentmcport
agentv6mcaddr
hostucport
interfacename
mastermcaddr
mastermcport
masterv6mcaddr
multicastttl
traffictype
$esxcli.vsan.network.ipv4.removeforce
interfacename
$esxcli.vsan.network.ipv4.setagentmcaddr
agentmcport
agentv6mcaddr
hostucport
interfacename
mastermcaddr
mastermcport
masterv6mcaddr
multicastttl
traffictype
$esxcli.vsan.network.list
$esxcli.vsan.network.removeforce
interfacename
$esxcli.vsan.network.restore
$esxcli.vsan.policy.cleardefault
$esxcli.vsan.policy.getdefaultpolicyclass
$esxcli.vsan.policy.setdefaultpolicy
policyclass
$esxcli.vsan.storage.adddisks
ssd
$esxcli.vsan.storage.automode.get
$esxcli.vsan.storage.automode.setenabled
$esxcli.vsan.storage.diskgroup.mountdisk
ssd
uuid
$esxcli.vsan.storage.diskgroup.unmountdisk
ssd
$esxcli.vsan.storage.listdevice
uuid
$esxcli.vsan.storage.removedisk
evacuationmode
ssd
uuid
$esxcli.vsan.storage.tag.adddisk
tag
$esxcli.vsan.storage.tag.removedisk
tag
$esxcli.vsan.trace.get
$esxcli.vsan.trace.setlogtosyslog
numfiles
path
reset
size

26 thoughts on “How to use ESXCLI v2 Commands in PowerCLI”

  1. Hi, how do I get the return values for the esxcli.network.diag.ping.Invoke($arguments) command?
    I need to know if the ping failed or succeded.

    1. The command creates a "VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliObjectImpl" object which you can use in further commands.
      If you just want to see the output, try something like this:


      $esxcli.network.diag.ping.Invoke($arguments) |Format-Custom -Depth 2

      class EsxCliObjectImpl
      {
      Summary =
      class EsxCliObjectImpl
      {
      Duplicated = 0
      HostAddr = 192.168.222.250
      PacketLost = 0
      Recieved = 2
      RoundtripAvg = 364
      RoundtripAvgMS = 0
      RoundtripMax = 373
      RoundtripMaxMS = 0
      RoundtripMin = 354
      RoundtripMinMS = 0
      Transmitted = 2
      }
      Trace =
      [
      class EsxCliObjectImpl
      {
      Detail =
      Dup = false
      Host = 192.168.222.250
      ICMPSeq = 0
      ReceivedBytes = 64
      RoundtripTime = 355
      RoundtripTimeMS = 0
      TTL = 64
      }
      class EsxCliObjectImpl
      {
      Detail =
      Dup = false
      Host = 192.168.222.250
      ICMPSeq = 1
      ReceivedBytes = 64
      RoundtripTime = 374
      RoundtripTimeMS = 0
      TTL = 64
      }
      ]

      }

  2. how would you set the software acceptance level? It looks like it would be $esxcli.software.acceptance.string.set (VMwareCertified) but that fails.

    thanks

  3. Hi, i'm trying to reset the password of an esxi.
    I had errors when i use Invoke
    $arguments = $esxcli.system.account.set.CreateArgs()
    $arguments.id = 'admin'
    $arguments.password = 'admin'
    $arguments.passwordconfirmation = 'admin'
    $arguments
    Name Value
    ---- -----
    passwordconfirmation admin
    id admin
    description Unset, ([string], optional)
    password admin

    $esxcli.system.account.set.Invoke($arguments)

    The XmlReader state should be Interactive.
    At line:1 char:1
    + $esxcli.system.account.set.Invoke($arguments)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException

    Any idea ?
    Did I set something wrong ?

    Thanks for your help

    1. I tested it and it works for me (Of course it must be a secure password, but the error message would tell if you didn't):

      $esxcli = Get-EsxCli -VMhost esx5.virten.lab -V2
      $arguments = $esxcli.system.account.set.CreateArgs()
      $arguments.id = 'admin'
      $arguments.password = '4!XdfF$$s'
      $arguments.passwordconfirmation = '4!XdfF$$s'
      $arguments
      
      $esxcli.system.account.set.Invoke($arguments)
      
      Name                           Value                                                                                                                                                      
      ----                           -----                                                                                                                                                      
      id                             admin                                                                                                                                                      
      passwordconfirmation           4!XdfF$$s                                                                                                                                                  
      description                    Unset, ([string], optional)                                                                                                                                
      password                       4!XdfF$$s                                                                                                                                                  
      true
      
      1. Hi fgrehl
        Yes you're right, it works the issue was the complexity of the password I set.
        Actually everything is working fine.
        Thanks for your help.

  4. Hi, how do I get the return values for the esxcli.iscsi.adapter.param.get($hba.device)command? Esxcli_v2 does not like this. Version 1, no problem.
    Here is what I get in -v2: Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.

    1. Did you use the Invoke Method, which is required in v2?

      Like this:
      $esxcli.iscsi.adapter.param.get.Invoke(@{adapter = 'vmhba64'})

      1. @fgrehl - THat worked like a charm! thanks for the quick response.
        Modified after your suggestion:
        $esxcli2.iscsi.adapter.param.get.Invoke(@{adapter =$hba}) | select Name, Current

  5. Hi, I am trying to use the "$esxcli.storage.nmp.satp.set"
    PowerCLI C:\> $args = $esxcli.storage.nmp.satp.set.CreateArgs()
    PowerCLI C:\> $args

    This is blank. No option to use the DefaultPSP or the SATP, can this be set in PowerCLI or do I need to go back to the Putty session and connect to each host to make this change?

    I was able to set the Custom Rule, but the defaultPSP still shows as MRU.

    1. The problem here is that you can't set $args in PowerShell. $args is reserved for arguments in functions.

      Use another variable and it should be fine:


      C:\> $arguments = $esxcli.storage.nmp.satp.set.CreateArgs()
      C:\> $arguments

      Name Value
      ---- -----
      defaultpsp Unset, ([string])
      boot Unset, ([boolean], optional)
      satp Unset, ([string])

  6. Great article and it has helped me out in some ways. However, I am not sure what I am doing wrong in the following example which is ran from a GUI.

    Function RemoveVib {
    $vmhost = $objectlist.SelectedItem.ToString()
    $vib = $dd_vib.SelectedItem.ToString()
    if ($vmhost.count -eq 0 -or $vmhost.count -gt 1) {$output.AppendText("Select Host and try again.`r`n")}
    elseif ($vib.count -eq 0) {$output.AppendText("Select VIBs and try again.`r`n")}
    else {$output.AppendText("Removing selected VIB...")
    $esxcli = Get-EsxCli -V2 -VMHost $vmhost
    $arguments = $esxcli.software.vib.remove.CreateArgs()
    $arguments.vibname = $vib
    $arguments.maintenancemode = $false
    if ($cb_force.checked -eq $true) {$arguments.force = $true}
    elseif ($cb_dryrun.Checked -eq $true) {$arguments.dryrun = $true}
    elseif ($cb_maint.Checked -eq $true) {$arguments.maintenancemode = $true}
    else {$output.AppendText("No methods selected`r`n")}
    $esxcli.software.vib.remove.invoke($arguments)
    $output.Appendtext("Complete!`r`n")
    $output.AppendText("A reboot may be required.`r`n")
    }
    }

    which works fine if I manually create the variable, but when it is made with the function the output is as follows: System.Collections.DictionaryEntry System.Collections.DictionaryEntry System.Collections.DictionaryEntry System.Collections.DictionaryEntry System.Collections.DictionaryEntry

  7. Good work.!!

    Need small help from you, If i run below command on ESXi i get
    #esxcli system settings kernel list -o iovDisableIR
    o/p
    Name Type Description Configured Runtime Default
    ------------ ---- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------- ------- -------
    iovDisableIR Bool Disable Interrrupt Remapping in the IOMMU. Not applicable for platforms pre-configured by firmware to use x2APIC (e.g., platformswith > 256 logical processors); for these interrupt remapping is always enabled. FALSE FALSE TRUE

    I want output for multiple ESXi and tried below
    PowerCLI C:\> $esxcli.system.settings.kernel.list

    ===================
    EsxCliMethodElement: list

    Methods:
    --------
    Hashtable CreateArgs()
    SettingsKernel[] Invoke(Hashtable args)
    string Help()

    Could you please help me to get same output for multiple hosts as in previous command on single ESXi.

  8. Excelent Article.
    I have a doubt.
    How can I "disconnect" a "get-esxcli" session.
    Example.
    If i run a script to get all paths in a host ESXi I use the following syntax to open the session:
    $example = get-esxcli -vmhost "esxihostname" -v2

    After that I run all the commands.

    But if I try to run the script again, it duplicates the results, because the variable $example it remains connected.

    How can I finish the connection of ESXI host. I didn't find any command to do this, like
    $example.exit or
    $example.quit or something like that.

    Someone how to know to do this?
    Thanks.

  9. Hi
    I want to remove the all storage devices, but getting the error message, not sure how to use -a argument to remove.

    PS C:\Users\admin> $esxcli=esxcli -V2
    PS C:\Users\admin> $esxcli.storage.core.device.detached.remove.help()

    =================================================================================================================================================================
    vim.EsxCLI.storage.core.device.detached.remove
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    Provide control to allow a user to remove Detached devices from the persistent detached device list.

    Param
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    - all | If set, all devices will be removed from the Detached Device List.

    - device | Select the detached device to remove from the Detached Device List.

    PS C:\Users\admin> $esxcli.storage.core.device.detached.remove - all
    At line:1 char:46
    + $esxcli.storage.core.device.detached.remove - all
    + ~
    You must provide a value expression following the '-' operator.
    At line:1 char:47
    + $esxcli.storage.core.device.detached.remove - all
    + ~~~

  10. This doesnt seem very intuitive to me , all i want to do is remove a vib called "net-mst" and i am going round in circles. Surely i am missing something glaringly obvious..!

  11. i am trying to get the network uplink status for all the physical nics of the esxi hosts in the vCenter server.

    $EsxHosts = Get-VMHost
    foreach($EsxHost in $EsxHosts){
    $esxcli = Get-VMHost $EsxHost | Get-EsxCli -V2
    $esxcli.network.nic.list.Invoke()
    }

    Can you please help to how to include hostname along with the phsyical status and export to csv format

  12. I am trying to get software acceptance info, but I am getting below error. Can someone help?
    $esxcli.software.acceptance.get.Invoke()

    Cannot find an overload for "Get" and the argument count: "0".
    At line:1 char:1
    + $esxcli.software.acceptance.get.Invoke()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

Leave a Reply

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