How to Install PowerShell on Rocky Linux 8

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 Rocky Linux 8 workstation or server. 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.

Update Rocky Linux

Before proceeding with the tutorial, it is good to ensure your system is up-to-date with all existing packages.

sudo dnf upgrade --refresh

Install PowerShell

Import GPG Key & PowerShell Repository

The installation of PowerShell is straightforward. First, import the GPG key with the following command.

sudo rpm --import

Next, import the Microsoft repo that contains the PowerShell application as follows.

sudo rpm -Uvh

Next, execute the following dnf install command to install the media player.

sudo dnf install powershell -y

How to Activate PowerShell

Now that you have completed the installation to activate PowerShell, use the following command.


Example of PowerShell Instance:

How to Install PowerShell on Rocky Linux 8

And that is it, and you have successfully installed the latest PowerShell version.

PowerShell Commands Example

Now that you have logged into your terminal, some common examples of using PowerShell are as follows.

Print Help


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 your system. This should be used even for workstation desktops, as sometimes GUI updates may be missed where the terminal will check everything.

sudo dnf update --refresh

How to Remove (Uninstall) PowerShell

When you no longer want PowerShell installed on your system, use the following command to remove it.

sudo dnf autoremove powershell -y

Next, remove the repository using the following command.

sudo rm /etc/yum.repos.d/microsoft-prod.repo

Comments and Conclusion

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.


Like to get automatic updates? Follow us on one of our social media accounts!