Installing PowerShell/PowerCLI on RHEL 7

Today I was reading about influxDB and Grafana as I am planning to deploy it in my lab to monitor my vSphere infrastructure and while going through the installation/configuration steps, I stumbled on one step where we needed to have powercli installed on the box where grafana is installed.

Since I am planning to deploy the influxdb/grafana on my centos 7 box, I started looking for how to configure PowerCLI on top of unix variants. Read few articles and finally deployed it my lab.

PowerShell Core v6.0 was released few days ago by Microsoft with support for Windows, Linux, and MacOS. Around same time, VMware released PowerCLI 10.0 which is VMware’s “PowerShell-like” utility. PowerShell version for linux can be downloaded from here

In this post I will be demonstrating installation of both PowerShell and PowerCli Core on RHEL 7 system. If you’re interested in installing this on other variants of linux then please consult this article. PowerCli core can also be installed via docker

All right enough of theory. Lets jump into action and do the deployment. Here are the steps:

1: Add the PowerShell Core repository in YUM Server

2: Install PowerShell

3: Launch PowerShell session

4: Verify PowerShell Version

5: Create trust for PSGallery

Since VMware PowerCLI has moved from being its own native installer to the PSGallery, the PSGallery needs to be “Trusted” before anything from it can be installed. To trust the PSGallery, entering the following command in the PowerShell session.

6: Install the VMware PowerCLI module

Note: If you want powercli to be available for all users that are present in the server, you can set the “Scope” parameter to AllUsers. Also to install a different version of powercli, you can specify the “RequiredVersion” parameter and supply the version number which you want to install.

power-4.PNG

8: Verify Installed Version of PowerCLI

power-5.PNG

9: Check all Installed modules

power-6.PNG

10: Import the installed modules

Note; On importing the module, you will notice that the SRM module is not yet supported in PowerShell Core. Hope this will be included in future release.

power-7.PNG

11: Check connection to vCenter Server

12: Try running few PowerCLI Commands

Note: If you get “InvalidCertificateAction setting ‘unset’ is not supported” error while trying to connect to vcenter server, then set the certificate checking to ignore by running below command: 

Also If you are annoyed by default message about joining CEIP, then you can disable that by running below command: 

Finally if you want to run powercli in unrestricted mode (to use use unsigned scripts) then you can do so by running command: pwsh -ep Unrestricted

Additional Reading

PowerCLI Core Documentation

And that’s it for this post. I hope you find this post informational. Feel free to share this on social media if it is worth sharing. Be sociable 🙂

Leave a Reply