Microsoft PowerShell is a versatile and industry-leading scripting language that can be used for automation. It is also often paired with other technologies like CI/CD platforms, making it possible to build solutions without much effort quickly! No matter what kind of input you are looking at, whether it’s text or object data, PowerShell will return .NET objects when executed; this means there is no need whatsoever to parse out information from output messages since all values are already inside them.
In the following tutorial, you will learn how to install PowerShell on Debian 11 Bullseye. The tutorial will use the
command line terminal with complete steps to install the official repository and tips on updating and removing the software securely and adequately.
Table of Contents
Before proceeding with the tutorial, it is good to ensure your system is up-to-date with all existing packages.
sudo apt update && sudo apt upgrade
The following dependencies will need to be installed. Most of these packages would already be present on your system, but running the command can help ensure they’re installed.
sudo apt install curl apt-transport-https gnupg2 -y
First, you will need to import the GPG and the repository. Luckily this is straightforward, and you will always have the most up-to-date version available on your Debian system.
Import the GPG key using the following command.
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor \ | sudo tee /usr/share/keyrings/powershell.gpg >/dev/null
The above command should work on most setups; any trouble, add
sudo to the command before
Next, import the repository.
echo "deb [arch=amd64,armhf,arm64 signed-by=/usr/share/keyrings/powershell.gpg] \ https://packages.microsoft.com/debian/11/prod bullseye main" \ | sudo tee /etc/apt/sources.list.d/powershell.list
Once done, run an APT update to reflect the new additional repository.
sudo apt update
Now you can install PowerShell using the following command.
sudo apt install powershell -y
Now that you have completed the installation to activate PowerShell, use the following command.
Example of PowerShell Instance:
And that is it, and you have successfully installed the latest PowerShell version on your Debian 11 system.
PowerShell Commands Example
Now that you have logged into your terminal, some common examples of how to use PowerShell are as follows.
Detail PowerShell information
List a directory
Print previous command history
List process information
Exit PowerShell instance
How to Update PowerShell
To check for updates using the command line, use the following command to allow a blanket check for any updates across all APT packages.
sudo apt update && sudo apt upgrade
How to Remove (Uninstall) PowerShell
When you no longer want PowerShell installed on your system, use the following command to remove it.
sudo apt autoremove powershell -y
Next, remove the repository using the following command.
sudo rm /etc/apt/sources.list.d/powershell.list
For good housekeeping and security, remove the GPG key as follows.
sudo rm /usr/share/keyrings/powershell.gpg
Comments and Conclusion
In the tutorial, you have learned how to install PowerShell on Debian 11 Bullseye.
Microsoft PowerShell is a powerful tool that can be used for system management and automation. If you’re not already familiar with PowerShell, we encourage you to check it out. It’s a great way to save time and automate tedious tasks.
More information about PowerShell and how to use it, amongst many other things, can be found in the official documentation.