How To Install PowerShell on Debian 11 | Easy Steps
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. How To Install PowerShell on Debian 11 is a common task for those managing heterogeneous environments.
Now, follow the steps below on the Orcacore website to install PowerShell on your Debian 11 system.
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:

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. Understanding How To Install PowerShell on Debian 11 allows for greater cross-platform compatibility.
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
Alternative Installation Methods
While the official method outlined above is the recommended approach, there are alternative ways to install PowerShell on Debian 11, although they might be less common or suitable for specific use cases. Here are two alternatives:
1. Using Snap Package Manager
Snap is a package management system developed by Canonical (the company behind Ubuntu) that allows you to install applications in a sandboxed environment. While not natively available on Debian, it can be installed and used to install PowerShell.
Explanation:
This method offers a convenient way to install PowerShell without directly manipulating APT repositories. Snap packages are self-contained, meaning they include all the dependencies required to run the application. This can be beneficial for avoiding dependency conflicts or managing different versions of PowerShell alongside other software. However, it’s important to note that Snap packages can sometimes be larger than APT packages due to the included dependencies, and the sandboxed environment might introduce slight performance overhead.
Steps:
-
Install Snapd:
First, install the
snapd
package, which provides the Snap daemon and command-line interface:sudo apt update sudo apt install snapd
-
Enable Snapd Socket:
Enable the snapd socket to ensure Snapd is running:
sudo systemctl enable --now snapd.socket
-
Install PowerShell via Snap:
Now, install PowerShell using the
snap install
command:sudo snap install powershell --classic
The
--classic
flag is necessary because PowerShell requires access to system resources beyond the standard Snap sandbox. -
Access PowerShell:
Once installed, you can run PowerShell by simply typing
pwsh
in your terminal. -
Remove Powershell
To remove powershell installed through snap, you can use the following command:sudo snap remove powershell
Caveats:
- Snap packages can be larger than traditional APT packages.
- The sandboxed environment might introduce some performance overhead.
- Requires installing and configuring Snapd on Debian.
2. Manual Installation from a Binary Archive
While less common, you can manually download a binary archive of PowerShell and extract it to a location on your system. This provides more control over the installation location and allows for more advanced configurations. This method can be useful if you require a specific version of PowerShell that is not available in the APT repository or through Snap.
Explanation:
This method involves downloading a pre-built binary package of PowerShell directly from Microsoft’s GitHub releases page. This allows you to bypass the APT package manager and manually configure the installation. It provides the most control over the installation process but also requires more manual configuration, such as setting up environment variables and creating symbolic links for convenient access. This method is best suited for advanced users who need to customize the PowerShell installation or use a specific version that is not available through other means.
Steps:
-
Download the Binary Archive:
Go to the PowerShell releases page on GitHub (https://github.com/PowerShell/PowerShell/releases) and download the appropriate binary archive for Debian 11 (usually a
.tar.gz
file for Linux). Ensure you select the correct architecture (e.g.,linux-x64
). -
Extract the Archive:
Extract the downloaded archive to a directory of your choice (e.g.,
/opt/powershell
):sudo mkdir /opt/powershell sudo tar -xf PowerShell-<version>-linux-x64.tar.gz -C /opt/powershell
Replace
<version>
with the actual version number of the downloaded archive. -
Create a Symbolic Link (Optional):
Create a symbolic link to the
pwsh
executable in a directory in your system’s PATH (e.g.,/usr/local/bin
) to make it easily accessible from the command line:sudo ln -s /opt/powershell/pwsh /usr/local/bin/pwsh
-
Set Environment Variables (Optional):
You might need to set environment variables, such as
POWERSHELL_HOME
, to point to the PowerShell installation directory. You can add these variables to your.bashrc
or.zshrc
file:echo 'export POWERSHELL_HOME=/opt/powershell' >> ~/.bashrc source ~/.bashrc
-
Access PowerShell:
Now, you can access powershell by typing pwsh in the terminal. -
Remove Powershell:
To remove powershell installed manually, you can delete the folder where you extracted the archive:sudo rm -rf /opt/powershell
If you have made a symbolic link you should also remove it:
sudo rm /usr/local/bin/pwsh
Caveats:
- Requires manually downloading and extracting the binary archive.
- Requires manually creating symbolic links and setting environment variables.
- More complex than using APT or Snap.
- Manual updates required by downloading and extracting new versions.
These alternative methods offer different approaches to installing PowerShell on Debian 11, each with its own advantages and disadvantages. Choose the method that best suits your specific needs and technical expertise. Remember to consider the ease of installation, maintenance, and potential impact on system resources when making your decision. The most common method of How To Install PowerShell on Debian 11 is through the apt repository.