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.

$DevHost = Get-EsxCli -VMHost devhost -V2
Notice I used the –V2 parameter. This means we are using version 2 of this cmdlet as version 1 is deprecated and compatibility is not guaranteed.
Now if we just run the output of $DevHost we see the “elements” we have to work with for this ESXi host.

Read more on Toms’s IT Pro


Leave a Reply

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

Related Posts

Technical

Restart multiple computers with the PowerShell PCSVDevice module

To restart multiple computers with PowerShell and without relying on functionality of the remote operating system, you can use the PCSVDevice module. The module contains several useful cmdlets for out-of-band management and supports the IPMI Read more…

Technical

Remotely migrate user data with USMT and PowerShell

USMT has been a staple for system administrators for years and has greatly reduced the time to migrate data between computers. USMT has the ability to migrate user files, OS settings, and application settings. It Read more…

Technical

Deploy VMware VMs with PowerCLI and MDT

If you are managing Windows servers, chances are you have a mix of physical and virtual servers in your data center. While VMware provides a method to create VMs from templates to simplify server deployments, Read more…