Introduction to PowerCLI

PowerCLI is a snapin for PowerShell that is intended for use with a VMware environment.  It can be found at:

http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli

Once launched, help can be found using the Get-VICommand commandlet or the Get-PowerCLIHelp commandlet.

powercli_3

To connect to a ESX/ESXi host, use the Connect-VIServer commandlet.  An example would be:

Connect-VIServer –Server IP address –Protocol https –User root –Password passwordvalue

Once connected, a message should be displayed:

powercli_1

Once connected to a host, commandlets such as Get-VM and Get-VMHost can be used.

powercli_2

The | format-list option can provide additional details.

powercli_4

powercli_5

More details can be displayed using the | Select-Object * option as well.

powercli_9

The Get-VMGuest commandlet will offer some additional details on a particular VM:

powercli_6

The Get-HardDisk commandlet pulls storage information:

powercli_7

The Get-DataStore commandlet can offer details on items such as free disk space available.

powercli_10

The Disconnect-VIServer commandlet will remove the connection to the host:

powercli_8