How to install and configure VMware PowerCLI version 10
VMware PowerCLI is a collection of Windows Powershell modules which are used to manage and maintain a VMware virtual environment. PowerCLI is a great tool for system administrators and can be used to gather detailed information and/or execute bulk commands against multiple VMs, Hosts, Network or Storage devices.
It is typically installed on Microsoft Windows based operating systems. A desktop or server must have network access to the VMware vCenter server(s) and be capable of running a minimum of Windows PowerShell 2.0 with .NET 3.5 SP1 pre-installed. However, it is highly recommended to install the very lastest official releases of Powershell and PowerCLI modules.
This step by step procedure is to prepare your system to run VMware PowerCLI Version 10 (released February 2018), configure shortcuts to your infrastructure and make the first connection to your vCenter server(s).
For this demonstration we are using Windows Server 2012 R2 (64 bit) to connect to a VMware ESXi 6.5 vCenter server. The user accounts have administrator rights in Windows & VMware.
- Check which version of Powershell is being used, and if applicable update it to the latest release (version 5 at time of writing).
- Open Powershell.
- Always use ‘Run as Administrator’ privileges. This can be done by navigating to (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) or search for Powershell on the start menu, right click on the powershell.exe application and choose Run As Administrator. You can also right click on any start menu or desktop shortcuts you may already have for Powershell.
- Type $psversiontable – this will tell you what version you are running. Look for the field “PSVersion”. In this example, I am running PSVersion 4.0:
- Upgrade your version of Powershell.
- To do this you will need to install Windows Management Framework (WMF) 5.1.
- Go to https://www.microsoft.com/en-us/download/details.aspx?id=54616:
- Select Download and then choose the version applicable to your operating system (in this example I have chosed the 64 bit version for Windows Server 2012 R2; if you are running Windows 10 (Creators Update) or Windows Server 2016, WMF is pre-installed by default):
- Once you have downloaded the .MSU file, Open it to start the WMF installer:
- You will then be prompted to install the WMF 5.1 update, click Yes:
- Accept the licence terms:
- The Update will install:
- Once the installation is completed, Reboot your server:
- After your server has rebooted, open Powershell (as administrator) and type $psversiontable to confirm you are now running PSVersion 5.1.
- WMF5.1 adds many features to Powershell but importantly it enables the ability to update modules directly from the Shell itself. If you are familiar with Linux, Powershell will now work like yum or apt-get when installing modules:
- Download and Install VMware PowerCLI module
- From your Powershell prompt enter:
Save-Module -Name VMware.PowerCLI -Path <path>
- Ensure you edit your path in the code above to your Powershell module path or any location you want to keep your modules [ eg. C:\Modules ]
- You will be prompted to approve the install – always select [Y] YES:
- Please note this process can take several minutes. You will see Powershell download all the modules. Once this is completed, Powershell will return to the default prompt:
- You can verify the files have downloaded by navigating to the path you chose to download too:
- Next you must install the modules into Powershell:
Install-Module -Name VMware.PowerCLI
- You will be asked to trust the installation, select [Y] Yes:
- This process can take several minutes to complete:
- From your Powershell prompt enter:
- Once completed, next you need to test the PowerCLI module is installed and available to PowerShell
- The first task to complete to ensure PowerCLI is correctly installed is to connect to your vCenter server via IP or DNS name.
- type connect-viserver YOUR IP ADDRESS:
- Yellow verbose text will be displayed as the connection to vCenter is established:
- Depending on your user account priviledges, you may be asked to log in, if you are, enter your credentials for the vCenter server
- You are connected to vCenter when you see this output from the shell. It displays the vCenter IP, the User connected and the port used:
- Now that you have confirmed you can connect, it is recommended to create a shortcut to automatically connect to your vCenter server so you are not manually connecting every time.
- On your Desktop, Right Click and Select new Shortcut:
- In the “Type your location” window enter %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command “connect-viserver YOUR-VCENTER-SERVER1 , YOUR-VCENTER-SERVER2 (Ensure you substitute your Actual IP addresses):
- Click Next and Enter a name for your shortcut (eg. PowerCLI Site X or PowerCLI Site Y):
- Click Finish to complete the process. You can now double click your new shortcut to directly connect to the vCenter Servers with PowerCLI