Now you can run PowerShell on both Linux and macOS

A version of PowerShell called PowerShell Core 6.0 has just been released by Microsoft, running on both macOS and Linux.

A cross-platform open source version of PowerShell called PowerShell Core 6.0 has just been released by Microsoft, not only running on Windows, but it can run on both macOS and Linux. In the near future, this version will also deploy with the original PowerShell we have used for 10 years.

Widely released from 10/1, PowerShell Core supports Windows 7+, Ubuntu, Redhat, Centos, macOS, Fedora, OpenSuse and Debian, allowing system administrators to use common administration scripting languages ​​to run on every server.

Microsoft has provided instructions for installing PowerShell Core for both macOS, Linux and Windows. On Windows, you only need to download and run the file to install PowerShell in parallel with the current PowerShell, thereby easily running the test and putting the current PowerShell script into PowerShell Core.

To install PowerShell on Linux and macOS, Microsoft releases packages for most Linux kernels. For example, installing PowerShell Core on Ubuntu 16.04, run the following command:

 # Import the public repository GPG keys 
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

# Register the Microsoft Ubuntu repository
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list

# Update the list of products
sudo apt-get update

# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell
pwsh

Once installed, start from the console with the pwsh command .

Now you can run PowerShell on both Linux and macOS Picture 1Now you can run PowerShell on both Linux and macOS Picture 1
PowerShell Core on Ubuntu 16.0 4

Unfortunately, for PowerShell Core to work on many OSs, Microsoft has to give up quite a bit of technology.

To switch to .NET Core and other OSs, we are forced to abandon some of the technologies being used on Windows PowerShell. We take advantage of PowerShell refactor to stop supporting some of the less-used technologies. Some will return to PowerShell Core but many of them are not. At a high level, there are:

  1. PowerShell Workflows
  2. PowerShell Snap-ins
  3. WMIv1 cmdlets (Get-WmiObject, Invoke-WmiMethod .) Encourage using CIM / WMIv2 cmdlets (Get-CimInstance, Invoke-CimMethod .)
  4. The Desired State Configuration (DSC) Executing resources use PowerShell Core

We also have many minor language changes, the engine and PowerShell cmdlets, which can technically be considered breakthroughs. For more information, please read Breaking Change at: https://github.com/PowerShell/PowerShell/blob/master/docs/BREAKINGCHANGES.md.

These changes will prevent existing PowerShell scripts from working on the Core without modification.

See more:

  1. How are Command Prompt (cmd) and PowerShell different?
  2. Instructions on how to use PowerShell in Windows Server 2012
  3. How to restart the computer using PowerShell
4 ★ | 21 Vote