Git with VS Code for Mac: Part 1 – Installing PowerShell and VMware PowerCLI

Ever since I wrote my blog series Git Integration with VS Code, I’ve been wanting to do a similar series of posts for those of us who primarily run MacOS. While a lot of the similar concepts from that series apply, I still wanted to go through the process step-by-step for those who may be completely new to this concept.

As a VMware administrator, I want the ability to write or update my PowerCLI scripts on GitHub from whatever system I have with me. Sometimes it may be my corporate-issued Windows device, and other times it might be my personal MacBook Pro. Regardless, I want to be able to synchronize my work on both systems and platforms. Now that both Microsoft PowerShell and Visual Studio Code are available on both platforms, I can work on either platform at any time and pick right up where I may have left off.

Much like my earlier Git Integration with VS Code (for Windows) series, I’ve broken this blog series down into the following parts:

  • Part 1 – Installing PowerShell and VMware PowerCLI (this post)
  • Part 2 – Installing and Configuring Git
  • Part 3 – Installing and Configuring Visual Studio Code
  • Part 4 – Syncing Content with GitHub

Installing PowerShell

Unlike Windows, MacOS does not come with PowerShell built into the operating system. In fact, the version of PowerShell that’s available for MacOS is technically known as PowerShell Core, which is a bit different from the native PowerShell version that’s built-in to Windows. If you want to deep-dive on how PowerShell and PowerShell Core are different, feel free to check out this post over on ghacks.net. So, there’s good chance that PowerShell isn’t on your system already.

Download Microsoft PowerShell

Microsoft has made PowerShell Core available for download via GitHub. The latest versions of PowerShell can be downloaded at github.com/powershell/powershell. In this example, I’ve downloaded the Stable .pkg file for macOS 10.12+. Once the download has finished, the installation can begin.

Download PowerShell Core for MacOS

Install Microsoft PowerShell on MacOS

To begin the installation process, double-click on the .pkg file you just downloaded and kick off the installation. In the Install PowerShell – Introduction window, click Continue to proceed.

Install PowerShell – Introduction

In the Install PowerShell – Installation Type window, click Install.

Install PowerShell – Installation Type

Once the installation is kicked off, MacOS may ask for authorization to make changes to the OS. Enter the appropriate credentials and click Install Software.

Authorize the new installation

After a moment or two, the installation will complete. Click Close to complete the PowerShell installation.

Install PowerShell – Summary

Launch PowerShell

Now that PowerShell is installed on MacOS, it can be run from within the Terminal window. For me, I typically launch the terminal by pressing Command + Space to bring up the spotlight search and type Terminal.

Once the Terminal window is open, launch PowerShell by typing:

pwsh
Launch Microsoft PowerShell within MacOS Terminal

Install VMware PowerCLI on MacOS

Now that Microsoft PowerShell is installed on MacOS, we can begin the installation of VMware PowerCLI. The install process is pretty straightforward, assuming Internet access is available. Open a new Terminal window (or use the same one from the previous step), and run the following command:

Install-Module -name VMware.PowerCLI
Install VMware PowerCLI

In the next step, PowerShell may ask if you want to trust the PSGallery repo. Enter Y (for Yes) or A (for Yes to all) to allow the download and installation to continue.

Trust the PSGallery repo

The installation will now download and install the modules that make up VMware PowerCLI. This process takes a few moments to complete. Progress bars will scroll (or flash) across the screen as the installation takes place.

VMware PowerCLI installation progress

Once the installation is complete, it will return to the regular Terminal command prompt. If you’d like to validate that the VMware PowerCLI installation was successful, run this command to list the installed VMware-related modules. In this screenshot, we can see that VMware PowerCLI version 11.2 is now installed on this system.

Get-Module -ListAvailable VMware*
A list of installed VMware PowerShell modules

If also put a video together on YouTube that walks you through the entire process outlined in this blog post.

As always, thanks for stopping by and be sure to check out Part 2 – Installing and Configuring Git.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s