How to list all the PowerCLI ESXCLI commands

PowerCLI logoLast week there was a question in the VMware VMTN Communities VMware vSphere PowerCLI forum from Papires who asked how you can convert the ESXCLI command ‘esxcli storage vmfs snapshot mount -l “DATASTORE”‘ into a PowerCLI command. I had not done very much with ESXCLI in PowerCLI, but I knew that it was something like ‘$esxcli.storage.vmfs.snapshot.mount’. However I was struggling with the ‘-l “DATASTORE”‘ part.

There is not much documentation available about the ESXCLI commands in PowerCLI. And also a search in Google did not help me very much. Finally I found the right answer using the PowerShell Get-Member cmdlet.

Using the Get-EsxCli cmdlet

If you want to use an ESXCLI command in PowerCLI you first have to create a EsxCliImpl object using the Get-EsxCli cmdlet. An example is shown in listing 2.

The Get-Member cmdlet output

The PowerCLI command ‘$esxcli.storage.vmfs.snapshot | Get-Member’ gave me the following output:

   TypeName: VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl

Name             MemberType   Definition
----             ----------   ----------
list             CodeMethod   vim.EsxCLI.storage.vmfs.snapshot.list.VMFSSnapshot[] list(string volumelabel, string volumeuuid)
mount            CodeMethod   boolean mount(boolean nopersist, string volumelabel, string volumeuuid)
resignature      CodeMethod   boolean resignature(string volumelabel, string volumeuuid)
extent           CodeProperty VMware.VimAutomation.Sdk.Util10Ps.ObjectCustomization.SimpleExtensionProperty
ConvertToVersion Method       T VersionedObjectInterop.ConvertToVersion[T]()
Equals           Method       bool Equals(System.Object obj)
GetHashCode      Method       int GetHashCode()
GetType          Method       type GetType()
help             Method       VMware.VimAutomation.ViCore.Types.V1.EsxCli.EsxCliHelp help(), VMware.VimAutomation.ViCore.Types.V1.EsxCli.EsxCliMethodHelp help(string methodName), VMware.VimAutomat...
IsConvertableTo  Method       bool VersionedObjectInterop.IsConvertableTo(type type)
ToString         Method       string ToString()
Client           Property     VMware.VimAutomation.ViCore.Interop.V1.VIAutomation Client {get;}
FullName         Property     string FullName {get;}
Id               Property     string Id {get;}
Name             Property     string Name {get;}
Uid              Property     string Uid {get;}

Listing 1. Output of the PowerCLI ‘$esxcli.storage.vmfs.snapshot | Get-Member’ command.

I now knew that the mount CodeMethod needs three parameters: nopersist, volumelabel and volumeuuid. Because Papires wanted to specify a volumelabel and probably wanted a persistent mount, I came to the following answer to his question.

$esxcli = Get-EsxCli -VMHost "YourHost"
$esxcli.storage.vmfs.snapshot.mount($false,"DATASTORE",$null)

Listing 2. PowerCLI equivalent of the ESXCLI ”esxcli storage vmfs snapshot mount -l “DATASTORE”‘ command.

The Get-EsxCliCommand function

Because I could find the right answer using the Get-Member cmdlet, I decided to write a PowerCLI script that can give me all the possible PowerCLI ESXCLI commands.

The Get-EsxCliCommand PowerCLI function lists all the possible PowerCLI ESXCLI commands. It does this by using the PowerShell Get-Member cmdlet to list each CodeProperty property and CodeMethod method of the EsxCliImpl or EsxCliElementImpl object that is given as input. Then the function calls itself for each CodeProperty. A function like Get-EsxCliCommand that calls itself is called a recursive function.

function Get-EsxCliCommand {
  <#
    .SYNOPSIS
      Lists all the possible PowerCLI ESXCLI commands.

    .DESCRIPTION
      Lists all the possible PowerCLI ESXCLI commands.

    .PARAMETER EsxCli
      The VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliImpl or VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl object for which all the possible PowerCLI ESXCLI command must be returned.

    .PARAMETER Name
      The top level name of the listed commands. The default is '$esxcli'.

    .EXAMPLE
      PS C:\> $esxcli = Get-EsxCli -VMhost ESX1.yourdomain.com
      PS C:\> Get-EsxCliCommand -EsxCli $esxcli

      Lists all the PowerCLI ESXCLI commands for server ESX1.yourdomain.com. 

    .EXAMPLE
      PS C:\> $esxcli = Get-EsxCli -VMhost ESX1.yourdomain.com
      PS C:\> Get-EsxCliCommand -EsxCli $esxcli.network -Name '$esxcli.network'
			
      Lists all the PowerCLI ESXCLI network commands for server ESX1.yourdomain.com. 

    .INPUTS
      VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliImpl
	  VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl
	  System.String

    .OUTPUTS
      System.String

    .NOTES
      Author: Robert van den Nieuwendijk
      Version: 1.0
      Date: 19-8-2012

    .LINK
      https://rvdnieuwendijk.com/

#>

  [CmdletBinding()]
  [OutputType([string])]
  param(
    [parameter(Mandatory=$true,Position=0)]$EsxCli,
    [parameter(Position=1)][String[]]$Name='$esxcli'
  )

  # Write the current command to the output stream
  [string]::Join('.',$Name)

  # List all the properties recursive
  $EsxCli |
    Get-Member -MemberType CodeProperty |
    ForEach-Object {
      if ($_)
      {
        # Call this function recursive for a sublevel
        $SubLevel = $_.Name
        Get-EsxCliCommand -EsxCli $EsxCli.$SubLevel -Name ($Name + $SubLevel)
      }
    }

  # List all the methods
  $EsxCli |
    Get-Member -MemberType CodeMethod |
    ForEach-Object {
      if ($_)
      {
        # Write the method to the output stream
        $SubLevel = $_.Name
        [string]::Join('.',$Name) + '.' + $SubLevel + '(' + $_.Definition.Split('(')[1]
      }
    }
}

Listing 3. The PowerCLI Get-EsxCliCommand function that lists all the possible PowerCLI ESXCLI commands.

You can use the Get-EsxCliCommand function as is shown in the examples in the code.

ESXCLI commands for vSphere 5

If you run the “Get-EsxCliCommand -EsxCli $esxcli -Name ‘$esxcli'” command for a VMware vSphere 5 host it will give the following output:

$esxcli
$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.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.memory
$esxcli.hardware.memory.get()
$esxcli.hardware.pci
$esxcli.hardware.pci.list()
$esxcli.hardware.platform
$esxcli.hardware.platform.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, boolean enabled, string nic, string option)
$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.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 type)
$esxcli.network.ip.dns
$esxcli.network.ip.dns.search
$esxcli.network.ip.dns.search.add(string domain)
$esxcli.network.ip.dns.search.list()
$esxcli.network.ip.dns.search.remove(string domain)
$esxcli.network.ip.dns.server
$esxcli.network.ip.dns.server.add(string server)
$esxcli.network.ip.dns.server.list()
$esxcli.network.ip.dns.server.remove(boolean all, string server)
$esxcli.network.ip.dns.help()
$esxcli.network.ip.interface
$esxcli.network.ip.interface.ipv4
$esxcli.network.ip.interface.ipv4.get(string interfacename)
$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)
$esxcli.network.ip.interface.ipv6.set(boolean enabledhcpv6, boolean enablerouteradv, string interfacename, boolean peerdns)
$esxcli.network.ip.interface.add(string interfacename, string macaddress, long mtu, string portgroupname)
$esxcli.network.ip.interface.list()
$esxcli.network.ip.interface.remove(string interfacename)
$esxcli.network.ip.interface.set(boolean enabled, string interfacename, long mtu)
$esxcli.network.ip.neighbor
$esxcli.network.ip.neighbor.list(string version)
$esxcli.network.ip.get()
$esxcli.network.ip.set(boolean ipv6enabled)
$esxcli.network.nic
$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.vswitch
$esxcli.network.vswitch.dvs
$esxcli.network.vswitch.dvs.vmware
$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.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.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(string device, string name, boolean nopersist, 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.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 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(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(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, 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.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.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.network
$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.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.settings
$esxcli.system.settings.advanced
$esxcli.system.settings.advanced.list(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(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.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, 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()

Listing 4. PowerCLI ESXCLI commands for a VMware vSphere 5.0 host.

ESXCLI commands for vSphere 4

The ESXCLI commands have changed much between vSphere 4 and vSphere 5. Because a lot of organizations still use vSphere 4, I also provide the vSphere 4 PowerCLI ESXCLI commands.

$esxcli
$esxcli.corestorage
$esxcli.corestorage.claiming
$esxcli.corestorage.claiming.autoclaim(string claimruleclass, boolean enabled)
$esxcli.corestorage.claiming.reclaim(string device)
$esxcli.corestorage.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.corestorage.claimrule
$esxcli.corestorage.claimrule.add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, long lun, string model, string plugin, long rule, long target, string transport, string type, string vendor)
$esxcli.corestorage.claimrule.convert(boolean commit)
$esxcli.corestorage.claimrule.delete(string claimruleclass, long rule)
$esxcli.corestorage.claimrule.list(string claimruleclass)
$esxcli.corestorage.claimrule.load(string claimruleclass)
$esxcli.corestorage.claimrule.move(string claimruleclass, long newrule, long rule)
$esxcli.corestorage.claimrule.run(string adapter, long channel, string claimruleclass, string device, long lun, string path, long target, string type, boolean wait)
$esxcli.corestorage.device
$esxcli.corestorage.device.list(string device)
$esxcli.corestorage.plugin
$esxcli.corestorage.plugin.list(string pluginclass)
$esxcli.network
$esxcli.network.connection
$esxcli.network.connection.list(string type)
$esxcli.network.neighbor
$esxcli.network.neighbor.list(string version)
$esxcli.nmp
$esxcli.nmp.boot
$esxcli.nmp.boot.restore()
$esxcli.nmp.device
$esxcli.nmp.device.list(string device)
$esxcli.nmp.device.setpolicy(boolean default, string device, string psp)
$esxcli.nmp.fixed
$esxcli.nmp.fixed.getpreferred(string device)
$esxcli.nmp.fixed.setpreferred(boolean default, string device, string path)
$esxcli.nmp.path
$esxcli.nmp.path.list(string device, string path)
$esxcli.nmp.psp
$esxcli.nmp.psp.getconfig(string device, string path)
$esxcli.nmp.psp.list()
$esxcli.nmp.psp.setconfig(string config, string device, string path)
$esxcli.nmp.roundrobin
$esxcli.nmp.roundrobin.getconfig(string device)
$esxcli.nmp.roundrobin.setconfig(long bytes, string device, long iops, string type, boolean useANO)
$esxcli.nmp.satp
$esxcli.nmp.satp.addrule(string claimoption, string description, string device, string driver, boolean force, string model, string option, string psp, string pspoption, string satp, string transport, string vendor)
$esxcli.nmp.satp.deleterule(string claimoption, string description, string device, string driver, string model, string option, string psp, string pspoption, string satp, string transport, string vendor)
$esxcli.nmp.satp.getconfig(string device, string path)
$esxcli.nmp.satp.list()
$esxcli.nmp.satp.listrules(string satp)
$esxcli.nmp.satp.setconfig(string config, string device, string path)
$esxcli.nmp.satp.setdefaultpsp(string psp, string satp)
$esxcli.swiscsi
$esxcli.swiscsi.nic
$esxcli.swiscsi.nic.add(string adapter, string nic)
$esxcli.swiscsi.nic.list(string adapter)
$esxcli.swiscsi.nic.remove(string adapter, string nic)
$esxcli.swiscsi.session
$esxcli.swiscsi.session.add(string adapter, string isid, string target)
$esxcli.swiscsi.session.list(string adapter, string target)
$esxcli.swiscsi.session.remove(string adapter, string isid, string target)
$esxcli.swiscsi.vmknic
$esxcli.swiscsi.vmknic.list(string adapter)
$esxcli.swiscsi.vmnic
$esxcli.swiscsi.vmnic.list(string adapter)
$esxcli.vaai
$esxcli.vaai.device
$esxcli.vaai.device.list(string device)
$esxcli.vms
$esxcli.vms.vm
$esxcli.vms.vm.kill(string type, long worldid)
$esxcli.vms.vm.list()

Listing 5. PowerCLI ESXCLI commands for a VMware vSphere 4.1 host.

Using help

Something that is not clear from listing 4 and 5 is that a lot of the esxcli commands provide help. E.g. I could type the command “$esxcli.storage.vmfs.snapshot.help()” and get the following output:

=========================================================================
vim.EsxCLI.storage.vmfs.snapshot
-------------------------------------------------------------------------
Manage VMFS snapshots.

ChildElement
-------------------------------------------------------------------------
- storage.vmfs.snaps | Manage VMFS snapshot extents.
  hot.extent         |

Method
-------------------------------------------------------------------------
- list               | List unresolved snapshots/replicas of VMFS volume.
- mount              | Mount a snapshot/replica of a VMFS volume.
- resignature        | Resignature a snapshot/replica of a VMFS volume.

Listing 6. Help of the $esxcli.storage.vmfs.snapshot command.

You will not see all the help commands in listing 4 and 5 because most help methods are of membertype Method and the function only shows methods of membertype CodeMethod.

About Robert van den Nieuwendijk
Robert van den Nieuwendijk is a freelance senior systems engineer with over 30 years of experience in the IT industry. He focusses on VMware vCloud Suite and Microsoft Windows Server. He tries to automate as much of his work as possible using Microsoft PowerShell. Robert is the author of the books “Learning PowerCLI” and “Learning PowerCLI – Second Edition.” Robert is a frequent contributor and moderator at the VMware VMTN Communities. He has a bachelor degree in software engineering and holds the following IT certifications and accreditations: VSP 2016, VTSP 2016, VCP4-DCV, VCP5-DCV, VCP6-DCV, VCP6-CMA, VCA-Cloud, VCA-WM, VCA-NV, VMSP, VMTSP, ZCS, ZCP, ZCP-Cloud, MCSE, MCSA, MCP, MCP+I, PRINCE2 Foundation and ITIL Foundation. In 2012, 2013, 2014, 2015, 2016, 2017, 2018 and 2019 Robert received the VMware vExpert award for his contribution to the community of VMware users over the past year. In 2017 Robert also received the VMware vExpert Cloud award. PernixData made him in 2015 a member of the PernixPro.

12 Responses to How to list all the PowerCLI ESXCLI commands

  1. Ryan Hammond says:

    Hi Robert – Thanks very much for your quality scripting tutorials, they have been very useful. I have a question on the listing #2 above – “DATASTORE” – how/where do you go to get this volumelabel? – I get this error when I put in what I presume to be correct:

    No unresolved VMFS snapshots with volume label ‘datastore1’ found.
    At line:1 char:36
    + $esxcli.storage.vmfs.snapshot.mount <<<< ($false,"datastore1",$null)
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationException

    Any help would be great!

    • Hi Ryan,

      thanks for your response to my blogpost. I am glad you like my scripting tutorials.

      Your datastore1 is probably not an unresolved VMFS snapshot. You can get all the unresolved VMFS snapshots for a host with the command:

      $esxcli.storage.vmfs.snapshot.list()

      See for more information:
      http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1011387

      Regards, Robert

      • Ryan Hammond says:

        Robert, I issued this command:
        $esxcli.storage.vmfs.snapshot.list()
        and nothing returns – total rookie question I’m sure, but – I’m connected to the vCenter server, and was able to set the $esxcli variable, but could it be I must be connected to the ESXi host itself to get results from this $esxcli.storage.vmfs.snapshot.list()? or, is it possible that I just don’t have any ‘unresolved VMFS snapshot’ on this Cluster?

  2. Ryan, you don’t have to connect to the ESXi host directly. You can test that with another command. E.g. $esxcli.network.ip.interface.ipv4.get(). That command should give some output. It is possible that you don’t have any ‘unresolved VMFS snapshots’ in this cluster.

  3. Adam Moore says:

    Hi Robert,
    Rookie question here. How to do create this object so it always loads when the VMware modlues are loaded.

    Thanks again for all help!!

    • Hi Adam,

      if you want the Get-EsxCliCommand function to be available when you use PowerCLI then there are several options. You can add the function to your PowerShell profile. You can edit your profile with typing “Notepad $profile” in PowerShell. You can also create a PowerShell module and put all the functions that you want to include in your PowerCLI sessions in this module. You can import the module with: “Import-Module modulename”. You can also add the Import-Module command to your profile.

  4. Pingback: BUG : HP ESXi 5.0 Complete Bundle Update 1.6

  5. Pingback: Howto use ESXCLI in PowerCLI | Virten.net

  6. Pingback: Creating custom SATP claimrules for EMC Symmetrix

  7. Pingback: Confluence: IT - Enterprise Server Platform

  8. Pingback: ESXCLI Commands mit PowerCLI ausführen – heiter bis wolkig

  9. Pingback: Run esxcli commands via PowerCli – https://cliffcahill.com

Leave a comment