Install PowerShell and PowerCLI on CentOS 7 Linux

I never thought I’d be doing this, but here’s how to install PowerShell (yes, that Powershell) on our beloved GNU/Linux. I need it because I want to automate some VMware tasks and PowerCLI is available for Linux through powershell.

curl https://packages.microsoft.com/config/rhel/7/prod.repo -o- | sudo tee /etc/yum.repos.d/microsoft.repo
sudo yum install -y powershell

Now powershell is installed, on GNU/Linux! Let’s contain our horror and keep moving forward. Open powershell and install the PowerCLI components.

pwsh
Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted"
Find-Module "VMware.PowerCLI" | Install-Module -Scope "CurrentUser" -AllowClobber
Import-Module "VMware.PowerCLI"

List what is available now with

Get-Module "VMware.*" -ListAvailable | FT -Autosize

And most VMware instances I’ve seen don’t have pristine ssl certs, so you might want to run:

Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore

Maintenance tasks include updating the PowerCLI modules.

Update-Module "VMware.PowerCLI"

References

Weblinks

  1. Shamelessly ripped from Install PowerShell and VMware PowerCLI on CentOS | iThinkVirtual
  2. Zsoldier’s Tech Blog: PowerCLI: The SSL connection could not be established, see inner exception.