Orange County, Tustin, CA 92780

Install VMware PowerCLI

download and install vmware powercli module

VMware regularly releases updates to its Powershell module, known as PowerCLI. While in the past you had to go to the vmware.com website, download the executable - by the way, you still can for older versions - and install PowerCLI, you no longer have to since there's an easier way directly from a PowerShell console.

If you do have an older version that was installed via an executable installer, please uninstall it via Apps & features under System Settings before proceeding with the examples shown here.

Assumption(s)Assumption(s) made:
You have vCenter Center Server joined to your domain and configured as an Identity Source if you want to login with domain credentials. Otherwise, you'll need to log in with local credentials like the SSO account, This email address is being protected from spambots. You need JavaScript enabled to view it..

Don't have this configured? Learn how to: Join VMware vCenter Server to Windows Active Directory and add AD as Identity Source

Checking PowerShell Version

There is a requirement for installing PowerCLI, and that is to have, at a minimum, PowerShell 3.0 installed. If you have the latest Windows 10 release, you will have no problem installing it. If you need to verify the version installed on your system, run the following command and look for the PSVersion in the output:

$PSVersionTable

The text will be the output you should see:

PS C:\> $PSVersionTableName Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

The installed version on my machine is PSVersion 5.1.18362.145 or simply 5.1, as highlighted on line 4.

How To Install PowerCLI

Warning! Open up a PowerShell console with admin privileges before trying to install PowerCLI.

Run the following command to install the latest version of PowerCLI.

Install-Module VMware.PowerCLI

If you need to install a specific version of PowerCLI, you may run the following:

Install-Module -Name VMware.PowerCLI -RequiredVersion 10.1.1.8827524

To list all the versions available for install, type the following:

Find-Module -Name VMware.PowerCLI  -AllVersions | Format-Table -AutoSize

Uninstall PowerCLI

To uninstall PowerCLI, type the following command to include all available versions of the module: 

Get-Module -Name VMware* -ListAvailable | Uninstall-Module -Force

 Connect to VMware vCenter Server using PowerCLI

 First, let's save our credentials to a temporary variable by typing the following:

$cred = Get-Credential

You should see an authentication dialog box. Enter your credentials.

authentication dialog box

By creating a temporary variable that stores your credentials, you can log in to multiple vCenter Servers or reuse it to login again if you lose your connection to vCenter Server.

Next, type the command below and subsite the name of your vCenter Server.  The example here includes the name of my vCenter Server, vcenter.virtual.local.

Connect-VIServer -Server vcenter.virtual.local -Credential $cred

If you connect successfully, you will see the following output showing the name of your vCenter Server.

PS C:\> Connect-VIServer -Server vcenter.virtual.local -Credential $cred 
Name Port User
---- ---- ----
vcenter.virtual.local 443 VSPHERE.LOCAL\Administrator

Running Basic CMDLETs

Now that you've connected successfully, let's run the following cmdlets:

Get-Datacenter

Get-Cluster

Get-VMHost

Get-VM

Get-Datastore

As you can see, those basic cmdlets retrieve a lot of useful information on your environment.

Enjoy learning PowerShell.

Byron Zepeda

Byron Zepeda is a Senior Systems Engineer in Orange County, California, working with VMware vSphere, Citrix Virtual Apps, backups, and storage. As cloud technologies and automation become first-class citizens within IT organizations, he desires to share everything he learns and pass it on to others.