How To Install PowerShell on Ubuntu 22.04

In this guide, we intend to teach you How To Install PowerShell on Ubuntu 22.04.

PowerShell is an object-oriented automation engine and scripting language with an interactive command-line shell that Microsoft developed to help IT professionals configure systems and automate administrative tasks.

PowerShell, built on the .NET framework, works with objects, whereas most command-line shells are based on text. PowerShell serves as an automation tool for system administrators, employed in both IT departments and external entities, such as managed service providers, because of its scripting capabilities.

How To Install PowerShell on Ubuntu 22.04

Before you start to install PowerShell, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Ubuntu 22.04.

Now follow the steps below to complete this guide.

Set up PowerShell on Ubuntu 22.04

First, you need to update and upgrade your local package index with the following command:

sudo apt update && sudo apt upgrade

Then, you need to install the required packages on Ubuntu 22.04 with the command below:

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

Here you need to download the Microsoft repository GPG keys with the command below:

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

Next, you need to register the Microsoft repository GPG keys:

sudo dpkg -i packages-microsoft-prod.deb

Again, update your local package index:

sudo apt update

At this point, you can use the following command to install PowerShell on your server:

sudo apt install powershell -y

When your installation is completed, run the following command on Ubuntu 22.04 to switch bash to the PowerShell:

pwsh

You will get the following output:

Output
PowerShell 7.2.4
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /root>

If you want to download and install the latest version of Powershell in the future, you can run the commands below from your PowerShell console:

PS /root> sudo apt update && sudo apt upgrade

To exit from your PowerShell console, you can use the command below:

PS /root> exit

Remove PowerShell from Ubuntu 22.04

If you no longer want to use PowerShell on your server, you can easily run the command below to remove it:

sudo apt remove powershell

For more information, you can visit the PowerShell Documentation page.

Conclusion

At this point, you learn to Install PowerShell on Ubuntu 22.04.

Hope you enjoy using it.

You may be interested in these articles on the orcacore website:

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular