How to Install PowerShell on Ubuntu 22.04


PowerShell is Microsoft’s automation and configuration management solution that was initially only available for Windows. Now it is available for Linux and macOS too. It comprises of command line console, a scripting language that works across multiple platforms, and a configuration management framework.

This post will guide you on how to install PowerShell on Ubuntu 22.04 LTS through the following two methods:

1. Via Package Repository

2. Via Direct Download

Method#1 Installing PowerShell via Package Repository

Complete the below steps to install PowerShell on Ubuntu 22.04 LTS through Package Repository.

1. Update the list of packages using the below command:

$ sudo apt update

Provide your password to run the above command.

2. Then you will need to install some pre-requisite packages. Run the below command to install them:

$ sudo apt install -y software-properties-common apt-transport-https

3. Download the Microsoft repository package using the below command:

$ wget -q "https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb"

4. Install the downloaded package using the below command:

$ sudo dpkg -i packages-microsoft-prod.deb

5. Then run the update command as follows:

$ sudo apt update

6. Now run the below command to install PowerShell on your system:

$ sudo apt install powershell

You will be prompted to confirm the installation of PowerShell. Hit y and then the Return key to install PowerShell.

This will install PowerShell on your Ubuntu system.

Method#2 Installing PowerShell via Direct Download

Complete the below steps to install PowerShell on Ubuntu 22.04 LTS via the direct download method.

1. Visit the PowerShell Releases page and download the latest release of the PowerShell installer package. To download the current version of PowerShell (PowerShell 7.2.5), run the below command:

$ wget https://github.com/PowerShell/PowerShell/releases/download/v7.2.5/powershell-lts_7.2.5-1.deb_amd64.deb

2. Then install the PowerShell package using the below command:

$ sudo dpkg -i powershell-lts_7.2.5-1.deb_amd64.deb

You may encounter an error during the installation like shown in the screenshot below.

To resolve this error, run the above command with –force-overwrite as follows:

$ sudo dpkg -i --force-overwrite powershell-lts_7.2.5-1.deb_amd64.deb

This will resolve the issue and install PowerShell on your system.

Launch PowerShell

As PowerShell is a command line utility, you cannot launch it from the Desktop GUI as you would normally do with other applications.

To launch it, run the below command:

$ pwsh

Your Terminal prompt will now be changed to PS /home/username>. You can now start using the PowerShell. To exit from PowerShell prompt, simply type exit and hit the Return key.

Uninstall PowerShell

To uninstall PowerShell, use the below command:

$ sudo apt remove powershell

Provide your password to uninstall it from your system.

I hope now you will be able to install PowerShell on Ubuntu 22.04 LTS using either of the ways discussed above. We also covered how to uninstall PowerShell from Ubuntu in case you want to remove it from your system. You can check out PowerShell’s official documentation for additional information.

Print Friendly, PDF & Email
Categories