How to Install PowerShell 7.1.0 via Apt Repository in Ubuntu 20.04, 18.04

Last updated: November 14, 2020

Microsoft PowerShell 7.1.0 was released a few days ago with a number of improvements and fixes to PowerShell 7. Here’s how to install it in Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, and Linux Mint 19.x, 20.

PowerShell 7.1.0 release highlights:

  • Fix $? to not be $false when native command writes to stderr.
  • Rename -FromUnixTime to -UnixTimeSeconds on Get-Date to allow Unix time input.
  • Make $ErrorActionPreference not affect stderr output of native commands.
  • Allow explicitly specified named parameter to supersede the same one from hashtable splatting.
  • Make the switch parameter -Qualifier not positional for Split-Path.
  • Resolve the working directory as literal path for Start-Process when it’s not specified.
  • Make -OutFile parameter in web cmdlets to work like -LiteralPath.
  • Fix string parameter binding for BigInteger numeric literals.
  • On Windows, Start-Process creates a process environment with all the environment variables from current session, using -UseNewEnvironment creates a new default process environment.
  • Do not wrap return result to PSObject when converting ScriptBlock to delegate.
  • Use invariant culture string conversion for -replace operator.

How to Install PowerShell in Ubuntu:

If you’re OK with containerized Snap package, simply search for and install powershell from Ubuntu Software.

For those prefer .deb package, Microsoft offers the software in its official apt repository.

1. Setup Microsoft apt repository in Ubuntu:

Open terminal from your system application launcher. When it opens, run command to download the official .deb package:

wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

For Linux Mint, replace $(lsb_release -rs) in the code with 20.04 for Linux Mint 20 (or 18.04 for Mint 19.x).

Then install the package, which will install Microsoft repository and key, by running command:

sudo dpkg -i packages-microsoft-prod.deb

Type user password (no asterisk feedback) for sudo prompts and hit Enter.

2. Install PowerShell:

After adding the repository, run following 2 commands one by one to check package updates and install the software:

sudo apt update

sudo apt install powershell

Once installed, run pwsh to start PowerShell.

Uninstall PowerShell:

To remove the software, simply open terminal and run command:

sudo apt remove powershell

To remove the apt repository, simply go to Software & Updates > Other Software tab, and remove the relevant line.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

3 responses to How to Install PowerShell 7.1.0 via Apt Repository in Ubuntu 20.04, 18.04

  1. Question is why I should even try powershell if I have my good and the best linux terminal? Because of Microsoft? Or what?