How to install Microsoft PowerShell on CentOS 9 Stream

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn how to install Microsoft PowerShell on CentOS 9 Stream.

So, according to Wikipedia:

PowerShell is a console interface with the ability to write and join commands via instructions. This console interface is designed for use by system administrators to automate tasks or perform tasks in a more controlled manner.

In addition to this, PowerShell includes a command tool that allows all sysadmin or developers to automate processes through scripts. It is somewhat similar to the shell we have in Unix-based systems, but a bit more focused on Microsoft products.

Let’s get started.

Install PowerShell on CentOS 9 Stream

As expected, PowerShell is not in the repositories of any Linux distribution. But this is no impediment for us to install and enjoy PowerShell on CentOS 9 Stream.

Installing PowerShell via the official repository

Fortunately, PowerShell has an official repository for CentOS 9 Stream. So, we can add it and get the latest stable version of it.

First, open a terminal and make sure the system is up-to-date:

sudo dnf update

Then install curl so we can download the GPG key.

sudo dnf install curl

Now, you can add the official repository with this command:

curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

Now run this command to install PowerShell

sudo dnf install powershell
1.- Install PowerShell on CentOS 9 Stream
1.- Install PowerShell on CentOS 9 Stream

And you’re done!

Another way: Install PowerShell without adding repositories

If you don’t feel comfortable adding repositories to the system, you can install a PowerShell RPM package to perform the installation.

To achieve this, first install wget

sudo dnf install wget 

Thereafter, you can download the latest stable version of PowerShell, which currently is 7.2.4.

sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.2.4/powershell-lts-7.2.4-1.rh.x86_64.rpm

This will automatically download and install the PowerShell package.

Running PowerShell

To run PowerShell, just type the following command:

pwsh
2.- PowerShell running
2.- PowerShell running

Conclusion

In this post, you learned how to install it on CentOS 9 Stream in what is a short tutorial that can help you continue your work on Microsoft products.

More CentOS 9 Stream posts

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

1 COMMENT

  1. For anyone running into problems:
    curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

    has turned into

    curl https://packages.microsoft.com/config/rhel/9.0/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

    and unfortunately the repo does not have powershell

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook