Archives For November 30, 1999

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 (7.4 Updated) 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, so far supports Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04.

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.

Microsoft PowerShell Core now can be easily installed in Ubuntu 18.04, Ubuntu 16.04 via Snap package.

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language.

It was announced on MSDN blogs:

    The goal of PowerShell Core is to be the ubiquitous language for managing your assets in the hybrid cloud. That’s why we’ve worked to make it available on many operating systems, architectures, and flavors of Linux, macOS, and Windows as possible.

    Today, we’re happy to announce an addition to our support matrix: PowerShell Core is now available as a Snap package.

How to Install PowerShell in Ubuntu via Snap:

Snap packages are containerized applications that can be installed on many Linux distributions. Snap bundles its dependencies in a single package and updates itself automatically once new version is published.

To install PowerShell snap, open Ubuntu Software, search for and install PowerShell Core:

or open terminal (Ctrl+Alt+T) and install it by running command:

snap install powershell --classic

NOTE for Ubuntu 16.04 users first time installing a snap package, install snapd before getting started:

sudo apt install snapd snapd-xdg-open