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.
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)
- PowerShell .pkg installer
- Homebrew package manager
- Homebrew's OpenSSL libraries
- .NET Core's cryptography libraries patch
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 /
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
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
brew install curl --with-openssl
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).
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).
- Open Source PowerShell (Microsoft)
- Microsoft open sources PowerShell; brings it to Linux and Mac OS X (ZDNet)
- 10 PowerShell commands to make remote management easier (TechRepublic)
- Ebook--Boost your Mac productivity with these 10 techniques (TechRepublic)
- Shell Scripting: Discover How to Automate Command Line Tasks (TechRepublic Academy)
- TR Dojo video: Five basic PowerShell commands Windows admins should know (TechRepublic)
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.