Share your love
How To Install PowerShell on Ubuntu 22.04

In this guide from the Orcacore website, 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.
Table of Contents
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.
1. Download Microsoft Repository 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 -y
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 following wget command:
sudo 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
2. Installing PowerShell in Ubuntu
At this point, you can use the following command to install PowerShell on your Ubuntu server:
sudo apt install powershell -y
Access PowerShell Console
When your installation is completed, run the following command on Ubuntu 22.04 to switch bash to PowerShell:
sudo pwsh
You will get the following output:

Update PowerShell
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 -y
To exit from your PowerShell console, you can use the command below:
PS /root> exit
3. 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 -y
For more information, you can visit the PowerShell Documentation page.
Conclusion
At this point, you have learned to install PowerShell on Ubuntu 22.04. PowerShell can be helpful for those who are familiar with PowerShell commands and the Windows environment.
Hope you enjoy using it. Please subscribe to us on Facebook and YouTube.
You may be interested in these articles:
Install PowerShell on Debian 12