PowerCLI in the PowerShell Gallery – how to and why?

PowerCLI is the best managing and automation tool for vSphere environments. I cannot imagine my work without this fantastic thing. The only one inconvenience I see in the PowerCLI is an installation procedure. In every single Windows I have to download and install .msi package. But now it has changed! We can find PowerCLI in the PowerShell Gallery – now there are two versions, and

How to install PowerCLI from the PowerShell Gallery?

Installation process is very simple. You just need to type the following command in your PowerShell (don’t forget to run as Administrator):

If you cannot install because of “The term is not recognized as the name of the cmdlet(…)” like on the screen below

The term is not recognized

it may means that your PowerShell version is too low, and you should install the appropriate version (PS 5.X would be the best). If you want to see more details about the installation process please visit VMware Blog, where it is described step by step.

PowerCLI in the PowerShell Gallery – but why?

There are several reasons why PowerCLI was added to the PowerShell Gallery. First of all, it is a simplification of deployment and usage. You don’t need to download and install a standalone package. Now you can deploy the whole PowerCLI by a few commands. With this method you can also run cmdlets directly in the PowerShell, without preparing the vSphere environment before or using the PowerCLI shell. But this is not the most important thing for me.

Automation. Automated deployments, automated installation on the various hosts, creating automated scripts for these jobs. Now it will be a lot simpler and easier to prepare massive installations and deployments. When you can use some commands to do something, you can also create a script! And if you have the script, you can do almost anything you want. There are some examples where you can find the installation by PowerShell Gallery useful:

  • PowerShell script for the AWS provisioning by the User Data
  • Jenkins jobs with the PowerShell usage
  • PowerShell scripts for preparing hosts, hosted on the Version Control System
  • Ansible playbooks for Windows configuration with the PowerShell usage

As you can see, PowerCLI in the PowerShell Gallery has many purposes and can simplify deploying the PowerCLI installation. You may have to do some configuration steps before using the PowerShell Gallery – it depends on how you use PowerShell on your hosts. For example, if you have never used the PowerShell Gallery, you have to set the PowerShell Gallery repository as trusted. You can do that with the following command:

You can create a universal PowerShell script which allows you to not only install PowerCLI, but also can unified your PowerShell environment in your whole Windows infrastructure.

Wanna more details? Take a look at:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.