search
top

Installing and Running PowerCLI on Linux

Introduction

The wait is over, you can now run PowerCLI on Linux. This is due to Microsoft PowerShell Core 6.x and .NET Core which includes the modules.

According to labs.vmware.com, PowerCLI Core uses Microsoft PowerShell Core and .Net Core to enable users of Linux, Mac and Docker to now use the same cmdlets which were previously only available on windows.

PowerCLI Core enables a multi-platform scripting language which will allow you to manage your VMware infrastructure on any OS. Scripts written previously against the windows version are now made portable to a number of operating systems and can simply be loaded and run on these new OS versions without change.

VMware PowerCLI is a command-line and scripting tool built on Windows PowerShell, and provides more than 600 cmdlets for managing and automating vSphere, vCloud, vRealize Operations Manager, vSAN, NSX-T, VMware Cloud on AWS, and VMware Horizon environments.

PreRequsites

As mentioned in the introduction PowerCLI is part of Microsoft PowerShell Core 6.x which we have covered in a previous post here. Now we can proceed to downloading and installing PowerCLI.

Downloading and Installing

Start pwsh session on Linux and have an Internet Connection, the Path will be where you want to save the downloaded modules

PS > Save-Module -Name VMware.PowerCLI -Path ~/

The following modules are downloaded

VMware.VimAutomation.Sdk
VMware.VimAutomation.Common
VMware.Vim
VMware.VimAutomation.Core
VMware.VimAutomation.Srm
VMware.VimAutomation.License
VMware.VimAutomation.Vds
VMware.VimAutomation.Vmc
VMware.VimAutomation.Nsxt
VMware.VimAutomation.vROps
VMware.VimAutomation.Cis.Core
VMware.VimAutomation.HA
VMware.VimAutomation.HorizonView
VMware.VimAutomation.PCloud
VMware.VimAutomation.Cloud
VMware.DeployAutomation
VMware.ImageBuilder
VMware.VimAutomation.Storage
VMware.VimAutomation.StorageUtility
VMware.VumAutomation

Now we can install the modules for your user ID, for this you will need to run the command

PS> Install-Module -Name VMware.PowerCLI -Scope CurrentUser

May get this popup

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure 
you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a

Modules will be installed to your home directory.

directory: .local/share/powershell/Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.7.0.8... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-DeployRule...}
Script     6.7.0.8... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile...}
Manifest   10.1.0.... VMware.PowerCLI
Script     6.7.0.8... VMware.Vim
Script     10.1.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script     10.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog...}
Script     10.1.0.... VMware.VimAutomation.Common
Script     10.1.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer...}
Script     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo
Script     7.1.0.7... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}
Script     10.0.0.... VMware.VimAutomation.License        Get-LicenseDataManager
Script     10.1.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtService}
Script     10.0.0.... VMware.VimAutomation.PCloud         {Connect-PIServer, Disconnect-PIServer, Get-PIComputeInstance, Get-PIDatacenter}
Script     10.1.0.... VMware.VimAutomation.Sdk
Script     10.0.0.... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}
Script     10.1.0.... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePolicy, Get-KeyManagementServer...}
Script     1.2.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script     10.1.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch...}
Script     10.0.0.... VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcService, Connect-VmcServer...}
Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition...}
Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance...}

We can check the installation and import the module in a single command

PS> Get-Module -ListAvailable VMware* | Import-Module

Note: May see an error for modules not supported.

WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following command:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true

VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and to advise you on how best to deploy and use our products. As part of the CEIP, VMware collects technical information about your organizations use of VMware products and services on a regular basis in association with your organizations VMware license key(s). This information does not personally identify any individual.

For more details: type "help about_ceip" to see the related help article.

To disable this warning and set your preference use the following command and restart PowerShell:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false.
Import-Module : The VMware.ImageBuilder module is not currently supported on the Core edition of PowerShell.
At line:1 char:1
+ Get-Module -ListAvailable VMware* | Import-Module
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (The VMware.Imag... of PowerShell.:String) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : The VMware.ImageBuilder module is not currently supported on the Core edition of PowerShell.,Microsoft.PowerShell.Commands.ImportModuleCommand

What’s Next

Now that we have PowerCLI installed, you can start exploring and connecting to VMware. Few usable links for PowerCLI  are here.

PowerCLI 10 Release Notes

PowerCLI  10 Users Guide

Cmdlet Reference

2 Responses to “Installing and Running PowerCLI on Linux”

  1. Micah says:

    Hi I am trying to follow your directions in order to install, but I am getting the following error:

    gt: The term ‘gt’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    Save-Module: Cannot find the path ‘~/modules’ because it does not exist.

    Do you happen to know why this is?

  2. Micah says:

    Ignore the previous reply, but I think I fixed it but I am now wondering about this error, I think something might be wrong with PSGallery for me but not sure what:

    PS /home/k610937> Save-Module -Name VMware.PowerCLI -Path ./modules
    WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’.
    Save-Package: /opt/microsoft/powershell/7-lts/Modules/PowerShellGet/PSModule.psm1:11792
    Line |
    11792 | $null = PackageManagement\Save-Package @PSBoundParameters
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | No match was found for the specified search criteria and module name ‘VMware.PowerCLI’. Try Get-PSRepository to see all available registered module repositories.

Leave a Reply

Your email address will not be published.

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

top