Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email
Reading Time: 3 minutes

In this article, I will go through the steps on how to install PowerShell Core on the Windows Subsystem for Linux. This can be useful for your scripting needs as it will give you a consistent language over both systems. You can also follow this guide to install PowerShell Core on a full Ubuntu Install. If you would like to see how to Install PowerShell Core on Windows you can read the how-to guide at this link.

Installing PowerShell Core

First, we need to find out what version of Ubuntu we are running. You can do that by using the following command.

# Check Version
lsb_release -a

Now that we have confirmed that we are running Ubuntu version 16.04 we can start to install PowerShell Core via a package repository. Now we need to import the public Microsoft repository. Use the following commands to do that.

# Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

And then enter your sudo password

We are now able to register the Microsoft Ubuntu repository. To do this use the following command.

# Register the Microsoft Ubuntu repository
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list

So that’s the repository imported and registered. Now, let’s run an update to make sure we are working with the most up to date files. Just use the following command.

# Update the list of products
sudo apt-get update

Finally, we are on to the fun stuff, actually installing PowerShell Core. As before just use the following command.

# Install PowerShell
sudo apt-get install -y powershell

That’s it you have now installed PowerShell Core! So how do we start it? It’s simple just follow on below.

Starting PowerShell Core

You cant get much simpler than this. You just need to type pwsh

# Start PowerShell
pwsh

You will notice the prompt has changed and now starts with PS that’s how you know you are in PowerShell Core. You can just type exit to return to the bash prompt.

To Uninstall PowerShell

Again this is really easy and can be accomplished with the small command below.

# Uninstall PowerShell
sudo apt-get remove powershell

Press y if prompted.

PowerShell Core has now been uninstalled! How easy was that?

Thanks for reading and I hope you found this article useful. If you have any questions feel free to reach out to me, I will be happy to answer any questions you might have.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *