How to install PowerShell and PowerCLI on macOS

We Live in the Cloud

How to install PowerShell and PowerCLI on macOS

19th March 2018 Scripting 0

I have been a huge fan of Microsoft PowerShell and VMware PowerCLI for many years now, using it to make life easier when managing and automating large virtual environments for my customers.  I was delighted that Microsoft open-sourced and released PowerShell Core 6.0, which now runs on a number of Operating Systems including Windows, Linux and macOS.  I am equally excited that VMware have now released VMware PowerCLI 10.0.0, which marks its 10th year anniversary and now has over 600 cmdlets!  The eagle eyed amongst you will notice that it is now called VMware PowerCLI, not vSphere PowerCLI.  This reflects that PowerCLI can manage so much more than just vSphere alone.

As a Mac user, I’ve seen articles about installing PowerShell, or PowerCLI, or Homebrew on a Mac, but none that take you from zero to PowerCLI hero, which is what this article aims to do in a step by step fashion.  At the end of the install guide I have included useful links and I have recorded the install of the pre-requisite Homebrew, then PowerShell, and finally PowerCLI on macOS to show you the feedback you should get after each stage.  It is worth noting that this will work for macOS 10.12 Sierra and above, but that I am using 10.13.3 High Sierra.  If in doubt, you can scroll down and watch the video of me doing the install.  Lets begin

Pre-requisits

  • Open a terminal
  • Install Homebrew (which is the missing package manager from macOS).  You can read more by visiting here, but for now, cut and paste the following

         /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

  • Install wget by typing brew install wget
  • Install Homebrew-Cask by typing brew tap caskroom/cask

Installing Powershell 6.0.2

  • brew cask install powershell
  • Should you wish to upgrade powershell at a later date you can type brew update brew cask reinstall powershell
  • To uninstall powershell you can type brew cask uninstall powershell

Installing PowerCLI 10.0.0

  • Now that you have PowerShell installed, start Powershell by typing pwsh
  • Here you will notice that the $ of terminal has now become the PS of PowerShell
  • Install-Module -Name VMware.PowerCLI -Scope CurrentUser
  • To update powercli type Update-Module VMware.PowerCLI

Please note, if you wish to install PowerShell on Linux, as there are so many distros, you should read the official install guide from Microsoft here.

If you already have PowerShell installed on Linux, Windows or macOS, then you simply start PowerShell and type the same command for all OSs, which I thought was pretty cool.  Install-Module -Name VMware.PowerCLI -Scope CurrentUser

That’s all folks, you’ve now successfully installed VMware PowerCLI. Useful links:

 

**UPDATE 26/04/18 The release of PowerCLI 10.1.0

What’s New?

– vSphere 6.7 support

– Import-VApp cmdlet now supports ovf and ova files that use SHA256 and SHA512

– Version parameters of New-VM and Set-VM, as well as Version property of the VirtualMachine object have been deprecated and replaced by HardwareVersion parameter/property, which accepts string input

– NSX-T views regenarated for NSX-T 2.1

– New module added VMware.Vim, which carries the vSphere low level binding libraries

– Two new cmdlets added to the DeployAutomation module – Remove-ScriptBundle, Set-ScriptBundleAssociation

– multiple bugfixes

You can read more and download it here:  https://code.vmware.com/web/dp/tool/vmware-powercli/10.1.0

Share and Enjoy !

0Shares
0 0 0