PowerShell on Linux

[Pages:40]WMLUG January 2017

PowerShell on Linux

Patrick TenHoopen

PowerShell on Linux

On August 18, 2016, Microsoft announced that it would make PowerShell open source and release it for Linux and Mac OS using one code base under the MIT license. It is still in an alpha stage though.

Why Run PowerShell on Linux?

Language is easily readable and is selfdocumenting

Optimized for structured data Good at "gluing" systems together Provides an interactive shell as well as being

scriptable

Comparing PowerShell to Bash

Command Input/Output Piping Bash uses text while PowerShell uses objects (does require that you know the object methods and properties). PowerShell doesn't support input redirection. Available Commands Bash has ~150 built-in commands and helper functions (less to learn) compared to PowerShell's 300+ (on Windows) methods and cmdlets. Windows System Integration PowerShell has many cmdlets written for administering Microsoft products while bash has none. Integrated Scripting Environment (ISE) PowerShell on Windows provides an integrated scripting environment.

PowerShell's Use of Objects

The output of a PowerShell command is an object. The object can be passed to the next command (object pipeline) for input.

Running on Linux

Not all of PowerShell's features work on Linux like in Windows due to bugs and the difference in frameworks (.NET Core on Linux vs full .NET on Windows). Some examples of issues: Remote management is not available Case-sensitivity of file names Aliases were removed for native commands (ls, cp,

etc.) so the native commands are used but they return text rather than objects

Running on Linux

Output from native commands is sent in total after command is done rather than as it is generated

Redirected output contains the UTF-8 byte order mark (BOM) unless ASCII encoding is specified

Job control doesn't work Doesn't do wildcard expansion (globbing) for the

native commands but does for built-in/internal commands

Installation

Supported distros: Ubuntu 16.04, Ubuntu 14.04, CentOS 7, Red Hat Enterprise Linux 7



Installing on Ubuntu 16.04:

sudo apt-get install libunwind8 libicu55 sudo dpkg -i /path/to/powershell_6.0.0-alpha.141ubuntu1.16.04.1_amd64.deb

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download