VMware PowerCLI

Installing VMware PowerCLI on Linux or macOS

Introduction

PowerCLI is a command-line interface for managing and automating all aspects of vSphere management, including networking, storage, VMs, guest OS, and more.
PowerCLI functions as a collection of PowerShell modules that contain more than 700 cmdlets (commands) to manage VMware infrastructure. PowerCLI runs on top of PowerShell. PowerShell used to be a Windows only shell. Since recent years Microsoft has made it possible to install PowerShell on Linux and macOS. This makes it possible to run VMware PowerCLI native on these operatin systems.

Installing PowerShell

Before we can install VMware PowerCLI we first need to install PowerShell.

Installation on Debian 11 via Package Repository

# Install system components
sudo apt update  && sudo apt install -y curl gnupg apt-transport-https
# Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# Register the Microsoft Product feed
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
# Install PowerShell
sudo apt update && sudo apt install -y powershell
# Start PowerShell
pwsh

Installation on Ubuntu 20.04 via Package Repository

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh

Installation on CentOS 8 / Alma Linux / Rocky Linux

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo yum install -y powershell
# Start PowerShell
pwsh

Installation of latest stable release via Homebrew on macOS 10.13 or higher

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install PowerShell
brew install --cask powershell
# Start PowerShell
pwsh

Installing VMware PowerCLI

You can install PowerCLI directly from the PowerShell Gallery.

Install-Module -Name VMware.PowerCLI

Verify the installtion succeeded.

Get-Module -Name VMware.PowerCLI -ListAvailable

Updating VMware PowerCLI

Updating the VMware Powercli Powershell modules can be easily done with the command below

Update-Module -Name VMware.PowerCLI

Conclusion

You are now ready to use VMware PowerCLI on you Linux or macOS system. All the available commands can be found in the VMware documentation here: VMware Developer Documentation.

Leave a Reply

Your email address will not be published.