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 three parts:
- Part 1 – Installing PowerShell and VMware PowerCLI (this post)
- Part 2 – Installing Git and Microsoft Visual Studio Code
- Part 4 – Configuring Git and VS Code (coming soon)
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.
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.
In the Install PowerShell – Installation Type window, click Install.
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.
After a moment or two, the installation will complete. Click Close to complete the PowerShell installation.
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:
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
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.
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.
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*
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 Git and Microsoft Visual Studio Code.