Using esxcli from PowerCLI

VMware offers more command-line interfaces for vSphere than PowerCLI. One of them is the vSphere Command-Line Interface (CLI). The vSphere CLI has a command named esxcli. PowerCLI has built-in support for this esxcli command in the Get-EsxCli cmdlet.

Note

There are no New-EsxCli, Set-EsxCli and Remove-EsxCli cmdlets. The Get-EsxCli cmdlet exposes the esxcli functionality for a host. You cannot create a new one, modify, or remove it.

The syntax of the Get-EsxCli cmdlet is as follows:

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

Use the Get-EsxCli cmdlet to connect to the esxcli functionality of a host and save the connection in a variable $esxcli:

PowerCLI C:\> $esxcli = Get-EsxCli -VMHost ...

Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.