How To Install PowerShell on Debian 11

[rank_math_breadcrumb]

Share your love

In this article, we want to teach you How To Install PowerShell on Debian 11. PowerShell is an open-source shell and scripting language built on top of Microsoft .NET technology. It aims to help tech pros who may not be software developers build efficient scripts and tools to help them do their job better.

Now, follow the steps below on the Orcacore website to install PowerShell on your Debian 11 system.

How To Install PowerShell on Debian 11?

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 on the Initial Server Setup with Debian 11.

Now follow the steps below to complete this guide.

1. Add PowerShell Repository and GPG Key

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 Debian 11 with the command below:

sudo apt install curl apt-transport-https gnupg2 -y

PowerShell is not available in the default Debian repository. So you need to add the PowerShell repo to the Debian repository with the command below:

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'

Next, add the GPG key with the following command:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Again, update your local package index:

sudo apt update

2. Install and Access PowerShell on Debian 11

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 Debian 11 to switch bash to the PowerShell:

pwsh

You will get the following output:

Access PowerShell on Debian 11

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

3. Remove PowerShell from Debian 11

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

Also, remove the repository with the following commands:

# sudo rm /etc/apt/sources.list.d/powershell.list
# sudo rm /etc/apt/sources.list.d/microsoft.list

Conclusion

At this point, you learn to install PowerShell on Debian 11. The installation process is straightforward using Microsoft’s official package repository, and once installed, PowerShell provides a powerful tool for automation, system administration, and cross-platform scripting. It’s a great addition for developers and sysadmins who want consistent scripting capabilities across Windows, Linux, and macOS.

Hope you enjoy using it. Please subscribe to us on Facebook, X, and YouTube.

You may be interested in other articles about PowerShell:

Install PowerShell on AlmaLinux 9 and RHEL 9

How To Install PowerShell on Ubuntu 22.04

Share your love

Stay informed and not overwhelmed, subscribe now!