• Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy
Cybersylum

Cybersylum

  • Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy

Installing PowerShell and PowerCLI on Linux

byArron King 04.07.2019 PowerCLI Scripting

Expanding the Lab

I’ve been working on changing some things in my lab lately, and wanted to build  a jumphost that I could get to from anywhere and use it to work on my VMware Virtualization lab.  While it would be pretty easy to setup a Windows machine, my lab dollars are hard to come by and I wanted to save every bit to grow the capacity.  Ever since PowerShell was made available on multiple platforms, I’ve wanted to try it out on Linux.Tux the Penguin and PowerShell

I am in no way a Linux expert; but have worked in multiple distros and am fairly comfortable – at least for non-production use.  I set up a VM with Ubuntu Desktop and applied all of the patches.  I’ll let others debate the virtues of the various Linux distributions.  I picked Ubuntu a while ago and it seemed to make sense to focus on a single distribution to best develop my expertise.  I chose Ubuntu Desktop as I wanted to have a GUI available should I be working remotely and needed to do a demo or work though something requiring a browser.

What do I need?

The toolset I need for my jumphost is fairly easy to assemble:

  • Modern Web Browser – Chrome and Firefox
  • PowerShell – This is Microsoft’s command-line shell and scripting language.  In the multi-cloud world in which we live in – this can be the tool to help automate all of these platforms together
  • PowerCLI – PowerCli is a PowerShell module for managing VMware vSphere
  • Tools for future projects  (such as Restful API automation, Desired State Configuration , etc)

As this is the initial build-out, this article will focus on installing PowerShell and PowerCLI.  There are two ways to install Powershell on Linux:

  1. Download the installer and run this on your target machine.
  2. You can also update the repository list on your machine and install the package.

For more details on the two methods, check out the Microsoft documentation for PowerShell Core.

Installation

My Ubuntu Linux VM is already confgured, patched and ready to go.  If you haven’t done this yet, this tutorial can help you get started.

 PowerShell

I opted to add PowerShell to my repository list as this would help keep the package updated as I patch the machine.  In a terminal window, enter the following commands to download the Microsoft Repository signature and then install it to your repo config.

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb


sudo dpkg -i packages-microsoft-deb

Download and install the Microsoft Repository signature

Now we need to refresh the package lists to include those from the new repository.

sudo apt-get update

Refresh package lists to include those from the new repository we just added

Once this has been done we can install PowerShell.

sudo apt-get install -y powershell

Installing Powershell with apt-get

PowerShell is installed and ready to go! To start PowerShell just type pwsh in a Linux shell.

Invoke PowerShell

PowerCLI

The next step is to install the PowerCLI module.  Tip:  when installing new modules into PowerShell, you must escalate privileges when you invoke PowerShell.

sudo pwsh

Starting PowerShell with escalated privileges for module installation

On to installing the PowerCLI module.

install-module -name VMware.PowerCLI

Installing the PowerCLI module

You will see a simple status while PowerCLI is installed.

Status messages while installing PowerCLI

So that’s it right?  With PowerShell and PowerCLI both installed, I should be able to run some commands against vCenter and start automating!

Getting to work

Let’s use PowerShell to connect to our vCenter and explore what we can do…

Connect-VIServer -server vcsa.cybersylum.com -user [email protected] -pass Don'tSharePasswords!

Self-signed certificate error

Since I am using the default self-signed certificate in my lab, I will get an error.  Fortunately, we can tell PowerCLI to ignore this issue if need be:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore

Udpating PowerCLI Certificate defaults to ignore self-signed certs

Now we should be able to connect to the vCenter server in the lab and run a basic command to list all VMs.

Connect-VIServer -server vcsa.cybersylum.com -user [email protected] -pass Don'tSharePasswords!

get-vm

Connecting to vCenter with PowerCLI and listing all VMs

That’s it – now you can run PowerShell from your Linux machine and build scripts to automate your VMware environment!  This is a very trivial example of what can be done.  PowerShell and PowerCLI together make a very powerful swiss army knife!

What’s Next

In future posts, I will discuss what you can do with PowerShell and PowerCLI now that you have it up and running.  If you haven’t done much with these tools and are eager to learn – there are a number of links with tips on getting started with PowerCLI in my vToolBelt posts you might want to check out.

 

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn

Images in Messages App are broken - Fixed!

vToolbelt - April 2019

2 thoughts on “Installing PowerShell and PowerCLI on Linux”

  1. Batou
    10.29.2019 at 10:28 am

    Super useful and well done, thank you very much!

    Reply
    • Arron King
      10.30.2019 at 3:11 pm

      Thanks for visiting -Glad you found it helpful!

      Reply
Leave a Reply Cancel reply

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

Search

Disclaimer

The content and opinions on this site belong to me - not my employer.

You are welcome to use any ideas or code from this site. You have the responsiblity to test these before using in a production environment.

Upcoming Events

  • Wed
    22
    Oct
    2025

    Cincinnati VMware VMUG UserCON

    Save The Date!

    The VMware VMUG UserCON returns to Cincinnati in October 2025

Categories

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10

Archives

Category

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10
Proudly powered by WordPress | Theme: Showme by NEThemes.
 

Loading Comments...