Yes! Now, PowerShell will be available CrossPlatform to help any system automation need. As a Linux newbie, I’m excited about this announcement.
So, if you have Linux Systems such as Ubuntu, CentOS, and, even for Mac OS X 10.11.
Check the link: https://github.com/PowerShell/PowerShell
Just go and get it. But, keep in mind, this is a work in progress.
This is PowerShell Core only, Alpha Version 184.108.40.206 and there’s a lot of work to do. Bugs and feedback are been submitted as the community are contributing for it success.
This version is also available for Windows 10 / Server 2016 and Windows 8.1 / Server 2012 R2. You can have it side-by-side with the current version of PowerShell.
Linux Installation Steps
Just follow the instruction provided in the GitHub PowerShell page, look for your Linux version, and follow the link provided for downloading installation package: https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#ubuntu-1604
In my case, I took the setup for Ubuntu 16.04:
1. Open a Terminal session.
2. run the following three commands:
$ sudo apt-get install libunwind8 libicu55
$ cd Downloads
$ sudo dpkg -i powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb
The first lines installs two dependencies needed before installing the package. Then, changing the folder to “Downloads”.
For those new to Linux, keep in mind, all command line sample is case-sensitive or it will not run.
After the installation is completed then you are ready to run PowerShell from any of the Linux Terminal applications.
- Open the “Terminal” application
- Then, type “powershell” (all in lowercase).
And, you try to run some cmdlet straight from Linux. But, are still some limitations, and there are some parameter that won’t work. Remember! This is an Alpha version.
You can’t build a remote PSSession (yet) and any use of the parameter “-computername ” will be limited to Linux systems.
So, a word of caution! if you try to use a cmdlet from Windows to access a Linux system, your Windows PowerShell session will crash.
All these issues will be handle soon.
Linux – Creating an Alias to call ‘powershell’
The following Linux commands will help to create the alias to call ‘powershell’. This way so you don’t type the whole name. The alias will be ‘Ps’ because there already is an existing one call ‘ps’.
Below are all the steps needed to create the alias:
1. Create a linux commands file by opening the gedit app.
$ sudo gedit Posh.sh
Add line -> powershell
2. After saving the file go and add permission.
$ sudo chdmod 755 Posh.sh
3. Need to make it Alias permanent and available when opening the Terminal app.
$ sudo gedit /etc/bash.bashrc
Add line -> alias Ps=/home/maxt/Posh.sh
4. This reset bash.
5. Testing the new alias
Now, you just type ‘Ps’ (case-sensitive) to open PowerShell in Linux. This way you’ll have the flexibility of using PowerShell when needed.
Linux PowerShell Editor – VS Code
In Linux, open Visual Studio Code:
From with in VS Code, you can open the “Terminal” session by using the hotkey combination “ctrl” +”\” +” ` “. So, at the $ prompt you can either type ‘powershell‘ or our new alias ‘Ps‘.
You can make your VS Code Terminal session or load PowerShell automatically by doing the following steps: Click “File -> Preferences -> User Settings”.
Then, on the opened Settings.json file and change to the following lines:
** for Linux **
** for Windows **
Remember to safe the file and you are set to work with PowerShell to build scripts.
This is an Awesome Time to learn PowerShell!