vSphere PowerCLI Reference

Get-EsxCli

Synopsis

This cmdlet exposes the ESXCLI functionality.

Syntax

Get-EsxCli -VMHost <VMHost[]> [-V2] [[-Server] <VIServer[]>] [<CommonParameters>]

Related Commands

Online version
Get-EsxTop

Detailed Description

This cmdlet exposes the ESXCLI functionality.

Note: This cmdlet provides a new interface to the ESXCLI functionality. Use the -V2 parameter to switch to the new cmdlet interface. For more information, check the parameter help.

Important: Scripts that use the old cmdlet interface might not be compatible across two different versions of ESXi. The old cmdlet interface is deprecated and will be removed in a future version.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
ServerVIServer[]Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsetrue (ByValue)
V2SwitchParameterIf specified, the cmdlet returns an EsxCli object version 2 (V2), otherwise an EsxCli object version 1 (V1) is returned. Interface V2 supports specifying method arguments only by name. This is the recommended PowerCLI interface for interoperability with ESXCLI. Interface V1 supports specifying method arguments only by position. Scripts that use interface V1 are not guaranteed to be compatible across two different versions of ESXi. Interface V1 is deprecated.falsefalse
VMHostVMHost[]Specifies hosts on which you want to expose the ESXCLI functionality.truetrue (ByValue)

Return Type

One EsxCli object per host

Notes

Supported on ESXi/vCenter Server 5.0 and later.

Examples

-------------- Example 1 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli_v1 = Get-EsxCli -VMHost $vmHost

Retrieves a version 1 interface to ESXCLI. This interface version is deprecated and will be removed in a future release. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 2 --------------

$esxcli_v1 = Get-EsxCli

Retrieves a version 1 interface to ESXCLI using the default connection when connected directly to a single ESXi server. This interface version is deprecated and will be removed in a future release. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 3 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2

Retrieves a version 2 interface to ESXCLI by specifying a version switch parameter. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 4 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$esxcli.storage.nmp

Retrieves a list of all available applications in the specified namespace. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 5 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$esxcli.storage.nmp.device

Retrieves a list of all available commands of the specified ESXCLI application. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 6 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli_v1 = Get-EsxCli -VMHost $vmHost
$esxcli_v1.storage.nmp.device.list()

Runs a command of an ESXCLI application by using the ESXCLI V1 interface of PowerCLI. This interface version is deprecated and will be removed in a future release. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 7 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$esxcli.storage.nmp.device.list.Invoke()

Runs a command of an ESXCLI application by using the ESXCLI V2 interface of PowerCLI. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 8 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$arguments = $esxcli.storage.nmp.device.set.CreateArgs()
$arguments

Creates an arguments hash table for a command of an ESXCLI application and prints argument info to the console, similar to the sample output below. This example uses the ESXCLI V2 interface of PowerCLI. This example works on vCenter Server 5.0/ESXi 5.0 and later.






Name Value
---- -----
default Unset, ([boolean], optional)
device Unset, ([string])
psp Unset, ([string], optional)

-------------- Example 9 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2

$arguments = $esxcli.storage.nmp.device.set.CreateArgs()
$arguments.device = "mpx.vmhba1:C0:T2:L0"
$arguments.psp = "VMW_PSP_MRU"
    
$esxcli.storage.nmp.device.Set.Invoke($arguments)

Creates an arguments hash table, assigns argument values and invokes a command of an ESXCLI application. This example uses the ESXCLI V2 interface of PowerCLI. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 10 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$esxcli.storage.nmp.device.Set.Invoke(@{default=$true; device="mpx.vmhba1:C0:T2:L0"})

Invokes a command of an ESXCLI application by specifying the arguments hash table in-line. This example uses the ESXCLI V2 interface of PowerCLI. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 11 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli_v1 = Get-EsxCli -VMHost $vmHost
$esxcli_v1.storage.nmp.device.set($null, "mpx.vmhba1:C0:T2:L0", "VMW_PSP_MRU")

Runs a command of an ESXCLI application by using the ESXCLI V1 interface of PowerCLI. This interface version is deprecated and will be removed in a future release. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 12 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$esxcli.TypeManager.QueryMoInstances($null)

Retrieves a list of all available managed object instance descriptors. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 13 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$moTypeInfo = $esxcli.TypeManager.QueryTypeInfo("vim.EsxCLI.storage.nmp.device")

$moTypeInfo.managedTypeInfo[0].method

Gets information about the specified managed object type (vim.EsxCLI.storage.nmp.device) and its methods.

-------------- Example 14 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$moInstance = $esxcli.TypeManager.CreateDynamicManagedObject("ha-cli-handler-storage-nmp-device")

$moInstance.InvokeOperation("list", $null)

Creates a dynamic managed object for the specified managed object instance descriptor and invokes a method without parameters. This example works on vCenter Server 5.0/ESXi 5.0 and later.

-------------- Example 15 --------------

$vmHost = Get-VMHost "vmHostIp"
$esxcli = Get-EsxCli -VMHost $vmHost -V2
$moInstance = $esxcli.TypeManager.CreateDynamicManagedObject("ha-cli-handler-storage-nmp-device")

$moInstance.InvokeOperation("set", @{"device" = "mpx.vmhba1:C0:T2:L0"; "psp" = "VMW_PSP_MRU"})

Creates a dynamic managed object for the specified managed object instance descriptor and invokes a method using a hash table with argument values. This example works on vCenter Server 5.0/ESXi 5.0 and later.


Copyright © VMware, Inc. All rights reserved.