Open Source

How to install Microsoft PowerShell 6.0 on macOS

Follow these steps to install Microsoft's open-source scripting environment, PowerShell, on macOS to aid in managing Windows and Unix-based systems from a Mac.

dev.jpg
Image: Rawpixel Ltd, Getty Images/iStockphoto

PowerShell, the framework developed by Microsoft for systems management and task automation, went open source on August 18, 2016. The announcement detailed plans by Microsoft to extend PowerShell to Unix-based operating systems, such as Linux distributions and Apple's macOS.

Immediately following the announcement, Microsoft established a GitHub repository with source code available for developers to use and binary packages for various OSes to get PowerShell installed on supported systems. In addition to Microsoft's continued support of the platform, there is also a community dashboard and chat room for support from other members of the PowerShell community.

Here's a tutorial on how to install PowerShell on macOS in order to make it easier to manage Windows and Unix-based systems from a Mac. Note: The current state of PowerShell for macOS is beta software, so bugs may exist that prevent certain features from performing optimally.

SEE: Ebook—Admin spotlight: Saving time with PowerShell (Tech Pro Research)

Requirements

  • PowerShell .pkg installer
  • Homebrew package manager
  • Homebrew's OpenSSL libraries
  • .NET Core's cryptography libraries patch

Installing PowerShell

After downloading the package, launch and follow the steps to install it or enter the command below to install it from Terminal (Figure A).

sudo installer -pkg /path/to/powershell-6.0.0-beta.3-osx.10.12-x64.pkg -target /

Figure A

201725figure-a.jpg


Uninstallation of PowerShell must be performed manually by executing the command below from Terminal (Figure B):

sudo rm -rf /usr/local/bin/powershell /usr/local/microsoft/powershell

Figure B

201725figure-b.jpg


Installing OpenSSL

If you haven't already installed Homebrew on your Mac, follow these steps to do so before proceeding.

Launch Terminal and execute the following commands separately to install the OpenSSL libraries on your Mac (Figure C) (Figure D).

brew install openssl

Figure C

201725figure-c.jpg


brew install curl --with-openssl

Figure D

201725figure-d.jpg


Patch .NET Core cryptography libraries

With PowerShell, Homebrew, and OpenSSL installed, the last step requires patching the .NET Core cryptography libraries so they utilize the OpenSSL libraries previously installed in Homebrew. Launch Terminal and execute the following commands separately:

find ~/.nuget -name System.Security.Cryptography.Native.dylib | xargs sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib

find ~/.nuget -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib

Once these steps have been completed, PowerShell and its dependencies will be fully installed and may be called upon by launching the Terminal and typing in powershell to enter the PowerShell command line interface (CLI) (Figure E).

Figure E

201725figure-e.jpg

To display a list of Modules and Cmdlets, type in the following lines separately to view a list of what's available by default. Bear in mind that PowerShell allows for cmdlets, which support other applications to be added by importing modules to the PowerShell session (Figure F) (Figure G).

Get-Module -ListAvailable

Figure F

201725figure-f.jpg
Get-Command -ListAvailable

Figure G

201725figure-g.jpg


Also see

Are you a systems administrator responsible for managing heterogeneous networks? Do you have experience with PowerShell and would like to share your thoughts? Sound off in the comments below.

About Jesus Vigo

Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from seve...

Editor's Picks

Free Newsletters, In your Inbox