Install Microsoft's Windows PowerShell On Linux

Here's the easiest way to get Microsoft Windows PowerShell working on your Linux system.
Warp Terminal

Microsoft and Open Source together do not surprise me anymore.

When Microsoft first announced that it is going to open source .NET, I was shocked. But then it open sourced Visual Studio CodeSQL Server, and more.

The last time I paid attention to Microsoft’s love for Open Source (and Linux) was when it announced Bash on Windows. That was big. Linux’s Bash Shell on Windows, thanks to Ubuntu.

When Microsoft announced that it was bringing its command line platform PowerShell on Linux. PowerShell is now open source and is available on Linux and macOS.

What is PowerShell?

PowerShell is a tool which lets you interact with the command-line shell and automate tasks, primarily for Windows. For things like starting a service, running a web request, you need to use the PowerShell (as an administrator) on Windows.

If we go by its official description, it is “a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework.

Basically, it’s a command line framework that allows administrative tasks on local and remote Windows systems, among other things. Tightly coupled with .NET, PowerShell has been a quite a hit in the Windows domain.

Install PowerShell on Linux using Snap

Linux already has more powerful and versatile shells available at its disposal. I don’t think regular Linux users are going to start using PowerShell, but then, that’s not the aim anyway. PowerShell on Linux is aimed at developers who must use PowerShell or .NET perhaps.

Whatever may be the reason for you to use PowerShell on Linux, you can easily install it using Snap.

First, make sure that Snap support is enabled on your Linux system. Thereafter, all you have to do is to use the following command:

sudo snap install powershell --classic
🚧
I was unable to make PowerShell as the default using the chsh command. It's acceptable since, there is an icon for PowerShell in the system menu.

If you would rather not use Snap, you can find installation instructions for various Linux distributions in its documentation. You can find docker images for some, and also find it listed in some of the popular package managers.

Install PowerShell using Microsoft Repository on Ubuntu

🚧
The repo you are going to configure below contains some .NET versions. Ubuntu's native repo provides many .NET packages too, but different versions. So keep caution while using .NET packages from this repo.

If you are using Ubuntu, you can set up the official Microsoft repository and install PowerShell from it. First, update your system:

sudo apt update

Now, you should install some prerequisite packages.

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

Now, get the version of Ubuntu you are using.

source /etc/os-release

Remember that, distributions like Pop!_OS, Linux Mint, etc. use Ubuntu at its base. So, on the next step, where we need the VERSION_ID, it implied the version code of Ubuntu, which the distribution is based.

Get the Ubuntu release version that is used by Pop!_OSGet the Ubuntu release version that is used by Pop!_OS
Get Ubuntu Version ID

Download and register the Microsoft repository keys. Just copy and paste the command, one by one.

wget -q <https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb>
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Now, you can update the software sources on the system and install PowerShell.

sudo apt update
sudo apt-get install -y powershell
📋
The repository includes a package for PowerShell LTS and Preview versions also.

That’s it. You can log in to PowerShell, by issuing the command:

pwsh 

Unlike the Snap version, there is no GUI icon to appear on the app menu.

Running Microsoft PowerShell in Linux. Neofetch program is executed to show system details.
Microsoft PowerShell in Linux
How to Change the Default Shell in Linux?
Tried another shell and liked it so much that you want to use it all the time by making it the default shell? Here’s how you can change the default shell in Linux.

For beginners, you can start learning PowerShell by following the PowerShell documentation. You can find more about it on its GitHub repository:

💬Have you tried PowerShell on Linux? Let me know your thoughts!

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.