Install VMwasre PowerCLi on Ubumtu 18.04

Print Friendly, PDF & Email




Howto Install VMware PowerCLI on Ubuntu 18.04


# Download the powershell '.tar.gz' archive
curl -L -o /tmp/powershell.tar.gz
or the preview op powershell 6.1

# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/6.0.2

# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/6.0.2

# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/6.0.2/pwsh

# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/6.0.2/pwsh /usr/bin/pwsh

or the preview op powershell 6.1

Download PowerCli

sudo pwsh
Install-Module -Name VMware.PowerCLI

Now try VMware PowerClI

Using PowerCLI
Once I had both PowerShell and PowerCLI installed, I created and ran a simple PowerShell script (PCL_Test.ps1) to test it:

Get-Module  -ListAvailable PowerCLI* | Import-Module
Connect-VIServer  -Server
Get-VM | Select  Name,VMHost, PowerState, MemoryGB
Get-VM | Select  Name, @{N="IP Address";E={@($_.guest.IPAddress[0])}}
$VMs = Get-VM |  Where-Object { $_.PowerState -ne "PoweredOff" -and  $_.Guest.GuestFamily -ne "WindowsGuest" }
$VMs.guest |  Select-Object VM,OSFullName,IPAddress

The start of the output of the script PCL_Test.ps1