Open Source PowerShell – Part 1
Summary: Find and install the Open Source PowerShell software for Linux or Windows.
I was reading up about a great new change in PowerShell. I heard that the newest version was Open Sourced on GitHub. Any chance you could give me a quick run-through to check it out?
Honorary Scripting Guy, Sean Kearney, is here today to bring you up to pace with the coolest new change that was introduced ever. The newest version of Windows PowerShell (version 6.0) is on GitHub.com as an Open Source project!
Don’t believe me? Check it out right now at https://github.com/PowerShell/PowerShell.
To say, “This is big,” is a very large understatement. It’s groundbreaking in what it brings forth. First off, consider the list of supported platforms in the current alpha release.
- Windows 10 / Server 2016
- Windows 8.1 / Server 2012 R2
- Ubuntu 16.04
- Ubuntu 14.04
- CentOS 7
- macOS 10.11
A supported cross-platform version of PowerShell is not just cool for Microsoft admins either. Just think of the possibilities. Unix admins can finally (after, of course, it eventually is RTM, naturally) take advantage of running Windows PowerShell scripts remotely.
This will allow them not only to capture the output of a Windows session but also the status code of the run script.
It also provides some of the amazing features that we in the PC world have long enjoyed about PowerShell, the consistent structure of the cmdlets and Help system. But, more importantly, PowerShell brings to the table the ability to easily convert various data types like JSON and consume them as objects.
ConvertFrom-String, can now take raw string output in a Linux environment and turn that into easily manipulatable objects.
Possibly the biggest piece is how PowerShell integrates into these environments. It does it on the environment’s terms. It’s just another Shell! It uses the same package installation process as any other Unix solution.
It also should be pointed out that Open Source PowerShell fully respects the XDG Base Directory Specification on Linux and macOS. This means something as simple as, “PowerShell sits in the proper folders on these systems, not ‘/Program Files/’”.
Now the fun part. Getting your hands on it.
The simplest method is really to just grab the install.sh script for Unix systems. This script will determine the parent *nix operating system and grab the appropriate package. It will also bring down any required dependencies that correspond to the version of Linux or macOS you’re running.
Just execute the following line to download the script.
After you have downloaded the file, you’ll need to make it an executable script by using chmod. You’ll be prompted for your credentials to elevate this in Linux and macOS.
sudo chmod +x download.sh
At this point, it will now download the binaries and begin to install them. After it’s done, you’ll be able to run PowerShell as you would in the PC world (except powershell is in all lowercase). Remember Linux and macOS are case-sensitive.
Now, if you like, you can even download the pkg or deb file (depending on your destination environment) and install it in the same normal manner as any other package in Linux or macOS.
It also means removal of PowerShell is exactly how you would expect it to be. It uses the solution that’s native to the environment.
For CentOS 7
sudo yum remove powershell
For Ubuntu 14/16
sudo apt-get remove powershell
Now, keep in mind this is Alpha software. It’s in development. It should do things that you don’t expect it to. This is not meant for a production system. But, it’s great to get your hands on it and get a feel for it.
Also, because this is an Open Source solution on GitHub, you can get your feedback directly to the team that’ developing it and contribute to its improvement.
Stop by next week, and I’ll go into how you can use it interactively with the Linux and macOS environments, just like you can with Bash or Python (or any other shell you presently have).
I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to them at email@example.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow.
Until then, always remember that with Great PowerShell comes Great Responsibility.
Sean Kearney Honorary Scripting Guy Cloud and Datacenter Management MVP