How to install PowerShell 7.1.0 via Apt repository on Ubuntu 20.04, 18.04

Microsoft PowerShell 7.1.0 was released a few days ago, with some improvements and fixes to PowerShell 7. This is how to install on Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, and Linux Mint 19.x, 20.

PowerShell 7.1.0 Release highlights:

  • Fix $? Not to $false When native commands write to stderr..
  • Rename -FromUnixTime To -UnixTimeSeconds on Get-Date Allows Unix time input.
  • create $ErrorActionPreference It does not affect stderr Native command output.
  • Allows an explicitly specified named parameter to replace the same parameter from hashtable splatting.
  • Create switch parameters -Qualifier Is not in the position of Split-Path..
  • Resolve the working directory as a literal path for Start-Process If not specified.
  • create -OutFile Web cmdlet parameters work as follows -LiteralPath..
  • Fixed string parameter binding for BigInteger Numeric literal.
  • On Windows Start-Process Use to create a process environment with all the environment variables in the current session -UseNewEnvironment Create a new default process environment.
  • Do not wrap the return result in PSObject When converting a ScriptBlock to a mandate.
  • Use immutable culture string conversion -replace operator.

How to install PowerShell on Ubuntu:

If you’re happy with the containerized Snap package, simply search for and install PowerShell from your Ubuntu software.

For those who like .deb Package, Microsoft provides the software in the official apt repository.

1. Set up the Microsoft apt repository on Ubuntu.

Open a terminal from the system application launcher. Once open, run the command to download the official .deb package.

wget -q$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

For Linux Mint $(lsb_release -rs) In the code 20.04 Linux Mint 20 (or 18.04 For Mint 19.x).

Then run the following command to install the package that installs the Microsoft repository and keys.

sudo dpkg -i packages-microsoft-prod.deb

Enter the user password for the sudo prompt (without asterisk feedback) and press Enter.

2. Install PowerShell.

After adding the repository, run the following two commands one at a time to check for package updates and install the software.

sudo apt update

sudo apt install powershell

Once installed, run pwsh Start PowerShell.

Uninstall PowerShell.

To remove the software, open a terminal and run the following command:

sudo apt remove powershell

To delete the apt repository[ソフトウェアとアップデート]>[その他のソフトウェア]Go to the tab and delete the relevant line.

Related Posts