How to Access ESXCLI with PowerCLI
If you have worked with vSphere, chances are you have had to perform some tasks on an ESXi host using ESXCLI. This command line interface created by VMware enables you to perform such tasks as installing software, configuring NIC adapters or seting firewall rules on ESXi. Since ESXi runs only Linux, using ESXCLI can be a bit daunting for Windows admins who don’t have much experience with Linux. Luckily, if you know PowerShell, you can use PowerCLI as a door into ESXCLI.
Connecting to an ESXi host
First, we need to connect to either a vCenter server or ESXi host. We can do this with the Connect-VIServer cmdlet. Keep in mind you can also connect to your vCenter server as well.
Connect-VIServer -Server devhost -Credential (Get-Credential)
Exposing ESX CLI
Now that we are connecting to our ESXi host “Devhost” we can use the Get-EsxCli cmdlet in PowerCLI to expose the ESXCLI functionality by placing it into a variable.