RHEL BasedRocky Linux

How To Install PowerShell on Rocky Linux 10

Install PowerShell on Rocky Linux 10

If you manage Linux servers in a hybrid environment, you already know the pain of juggling Bash scripts on one side and PowerShell automation on the other. The good news is that you can install PowerShell on Rocky Linux 10 and run the same .ps1 scripts you use on Windows, without rewriting a single line. This guide walks you through three battle-tested methods to get PowerShell up and running on your Rocky Linux 10 server, from the officially recommended DNF repository method to a direct RPM install for air-gapped environments. By the end, you will have a working pwsh shell, know how to verify it, and understand how to keep it updated.

What Is PowerShell and Why Does It Matter on Rocky Linux 10?

PowerShell is Microsoft’s open-source, cross-platform automation shell and scripting language built on top of .NET. It was originally a Windows-only tool, but Microsoft open-sourced PowerShell 6 in 2016 and has maintained active Linux support ever since.

The version you install on Linux is PowerShell 7.x, not the legacy Windows PowerShell 5.1 that ships with older Windows Server installs. PowerShell 7 receives active feature updates and security patches. The current stable release as of this writing is PowerShell 7.5.2.

Rocky Linux 10 is a community enterprise Linux distribution that is a downstream rebuild of Red Hat Enterprise Linux (RHEL) 10. Because Microsoft officially supports PowerShell on RHEL 8, 9, and 10, the same installation paths work on Rocky Linux 10 without any workarounds.

Why Install PowerShell on a Linux Server?

Here are the most practical reasons a sysadmin would want PowerShell on Rocky Linux 10:

  • Cross-platform script reuse: Run the same .ps1 automation scripts you already use on Windows without rewriting them in Bash.
  • Object-based pipeline: PowerShell passes structured .NET objects between commands instead of raw text strings, making data parsing far more reliable.
  • Azure and Microsoft 365 management: Many Azure CLI tasks, Exchange Online admin operations, and Microsoft Graph API interactions are built around PowerShell cmdlets.
  • Team standardization: Teams that already know PowerShell can manage Linux infrastructure without learning a second scripting language from scratch.
  • Long-term support: Microsoft supports PowerShell on RHEL 10 (and therefore Rocky Linux 10) until May 31, 2035.

Prerequisites

Before you run a single command, confirm you have everything in order. Skipping this step is the number one reason installations fail halfway through.

System requirements:

  • Rocky Linux 10 installed (physical machine, virtual machine, or cloud VPS)
  • A user account with sudo privileges, or direct root access
  • Active internet connection to reach Microsoft’s package servers or GitHub (for Methods 1 and 2)
  • Basic comfort with the Linux terminal and the DNF package manager

Recommended preparation:

  • Know your system architecture. These instructions cover x86_64. ARM64 builds are available separately.
  • For Method 2 (Snap), you need the EPEL repository enabled. The relevant step is covered below.

Run this command first to update your existing packages before adding anything new:

sudo dnf upgrade --refresh

This prevents dependency conflicts that can interrupt the installation later.

Method 1: Install PowerShell on Rocky Linux 10 via Microsoft DNF Repository (Recommended)

This is the officially supported method from Microsoft. It gives you automatic updates through DNF, GPG-signed packages verified against Microsoft’s signing key, and a straightforward upgrade path when new versions ship.

Step 1: Update Your System

Always start with a full package refresh. This ensures DNF has the latest package metadata and your current packages have no pending updates that could conflict with new installations.

sudo dnf upgrade --refresh

When DNF finishes, you will see a summary showing how many packages were updated. If nothing needed updating, you will see Nothing to do. Complete! — both outcomes are fine, so continue.

Step 2: Import the Microsoft GPG Signing Key

Before you add Microsoft’s repository, you need to import their GPG public key. DNF uses this key to cryptographically verify that every package you download genuinely came from Microsoft and was not tampered with in transit.

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

This command fetches Microsoft’s public key from packages.microsoft.com and registers it in your RPM keyring. You will not see any output if it succeeds — that is normal behavior for rpm --import.

Step 3: Add the Microsoft Package Repository

Now add Microsoft’s Linux package repository. Rocky Linux 10 uses the RHEL 10 repository path because it is a direct downstream rebuild of RHEL 10.

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

curl fetches the repository definition file from Microsoft’s servers. tee writes it to /etc/yum.repos.d/microsoft.repo, which is the directory DNF scans when looking for available repositories.

To confirm the repo was added correctly, run:

sudo dnf repolist | grep microsoft

You should see a line containing packages-microsoft-com-prod in the output.

Step 4: Install PowerShell

With the repository registered, install PowerShell in a single DNF command:

sudo dnf install powershell -y

DNF will resolve all dependencies automatically and pull the latest stable release from the Microsoft repository. The -y flag skips the confirmation prompt. The download is roughly 60-80 MB depending on which dependencies your system already has.

Expected output (abbreviated):

Installed:
  powershell-7.5.2-1.rh.x86_64

Complete!

Step 5: Verify the Installation

Once installation completes, confirm the binary is available and the version is correct:

pwsh --version

Expected output:

PowerShell 7.5.2

The binary name on Linux is pwsh, not powershell. This distinction matters when writing scripts or creating systemd service units.

Step 6: Launch PowerShell and Run a Basic Test

Start a PowerShell session:

pwsh

Your prompt changes to the PowerShell prompt:

PowerShell 7.5.2
PS /root>

Run this command to confirm the shell reports all environment details correctly:

$PSVersionTable

Expected output:

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Linux 5.14.0 ...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.0, 7.5.2}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This output confirms PowerShell is running on Rocky Linux 10, targeting the correct .NET runtime.

Method 2: Install PowerShell on Rocky Linux 10 via Snap

The Snap method is useful when your environment blocks external DNF repositories, or when you want to manage PowerShell updates through Snapd rather than DNF. This method requires the --classic flag to give PowerShell unrestricted system access.

Step 1: Enable the EPEL Repository

Snapd is not included in Rocky Linux 10’s default repositories. You need EPEL (Extra Packages for Enterprise Linux) first.

sudo dnf install epel-release -y

After installation, verify EPEL is active:

sudo dnf repolist | grep epel

Step 2: Install Snapd

Now install the Snapd daemon, which manages snap packages on your system:

sudo dnf install snapd -y

After the install, enable and start both the Snapd service and its socket:

sudo systemctl enable --now snapd.service snapd.socket

Then create the required symbolic link for classic snap packages to work correctly:

sudo ln -s /var/lib/snapd/snap /snap

Without this symlink, classic snaps including PowerShell will fail to install because they expect the /snap path to exist.

Step 3: Add the Snap Binary Path

The Snap binary directory is not in the default $PATH on Rocky Linux. Add it now so your system can find pwsh after installation:

echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | sudo tee /etc/profile.d/snap.sh
source /etc/profile.d/snap.sh

The first command creates a persistent profile script that adds the Snap bin path every time a user logs in. The second command loads it immediately for your current session.

Step 4: Install PowerShell via Snap

sudo snap install powershell --classic

The --classic flag grants PowerShell access to your full filesystem and system resources. Without it, the snap confinement would prevent PowerShell from reading files outside its sandbox, making it nearly useless for real sysadmin work.

Expected output:

powershell 7.5.2 from Canonical✓ installed

Step 5: Verify and Launch

pwsh --version
pwsh

The output and behavior are identical to Method 1. The shell is the same PowerShell binary — only the delivery mechanism differs.

Method 3: Install PowerShell on Rocky Linux 10 via Direct RPM Package

Use this method on servers with no outbound internet access (air-gapped environments) or in situations where adding external repositories violates your organization’s security policy. The trade-off is that this method does not provide automatic updates.

Step 1: Find and Download the Latest RPM

The official PowerShell RPM packages are published on GitHub Releases. The current stable package for RHEL/Rocky Linux x86_64 is:

https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell-7.5.4-1.rh.x86_64.rpm

On a machine with internet access, download it with:

curl -LO https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell-7.5.4-1.rh.x86_64.rpm

If you are working on an air-gapped server, transfer the downloaded .rpm file to the server using scp or your preferred file transfer method before continuing.

Step 2: Install the RPM Package

You can install directly from the URL if the server has internet access:

sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell-7.5.4-1.rh.x86_64.rpm -y

Or, if you downloaded the file locally first:

sudo dnf localinstall powershell-7.5.4-1.rh.x86_64.rpm -y

Using dnf instead of rpm -i is intentional. DNF resolves and installs any missing dependencies automatically, while rpm -i will fail if dependencies are not already present.

Step 3: Verify the Installation

pwsh --version

With this method, PowerShell will not update automatically. To update, download the new RPM from the GitHub releases page and repeat the dnf localinstall step.

How to Update PowerShell on Rocky Linux 10

Keeping PowerShell updated ensures you get security patches and new features. The update command depends on which installation method you used.

  • DNF (Method 1): sudo dnf update powershell
  • Snap (Method 2): sudo snap refresh powershell
  • Direct RPM (Method 3): Download the new RPM from GitHub Releases and run sudo dnf localinstall powershell-*.rpm -y

For production servers using Method 1, consider enabling dnf-automatic to apply security updates without manual intervention.

How to Uninstall PowerShell from Rocky Linux 10

If you need to remove PowerShell, the command depends on how you installed it.

  • DNF method: sudo dnf remove powershell -y
  • Snap method: sudo snap remove powershell
  • Direct RPM method: sudo dnf remove powershell -y

After removal, confirm the binary is gone:

which pwsh

If which returns nothing, the uninstall was successful. You can also remove the Microsoft repository file if you no longer need it:

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

Troubleshooting Common PowerShell Installation Issues on Rocky Linux 10

Even on a clean system, a few things can go wrong. Here are the most common problems and exactly how to fix them.

Error 1: “pwsh: command not found” After Snap Install

Cause: The Snap binary directory /var/lib/snapd/snap/bin is not in your current $PATH.

Fix: Reload the path profile and try again:

source /etc/profile.d/snap.sh
pwsh --version

If the problem persists after reloading, log out and log back in so the profile change takes effect system-wide.

Error 2: GPG Key Verification Failed During DNF Install

Cause: The Microsoft GPG key was not imported before the repository was added, or the import failed silently.

Fix: Re-run the import command and then clear the DNF cache before retrying:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf clean all
sudo dnf install powershell -y

Error 3: Repository 404 or “No match for argument: powershell”

Cause: The repository config file points to the wrong RHEL version path. This happens when users copy a RHEL 8 or RHEL 9 guide without updating the version number.

Fix: Confirm your OS version and re-add the correct repository:

cat /etc/os-release
curl https://packages.microsoft.com/config/rhel/10/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
sudo dnf install powershell -y

Rocky Linux 10 must use the /rhel/10/ path, not /rhel/8/ or /rhel/9/.

Error 4: Snap Install Hangs or Returns a Socket Error

Cause: The snapd.socket unit is not running, which is common right after a fresh Snapd install.

Fix:

sudo systemctl enable --now snapd.socket
sudo systemctl restart snapd
sudo snap install powershell --classic

Error 5: Dependency Errors During DNF Install

Cause: Outdated package metadata or missing base dependencies from a minimal Rocky Linux 10 install.

Fix: Run a full system upgrade first, then retry:

sudo dnf upgrade --refresh
sudo dnf install powershell -y

Quick Reference: All Three Methods Side by Side

Feature DNF + Microsoft Repo Snap Direct RPM
Auto-updates Yes (via dnf update) Yes (via snap refresh) No (manual only)
Requires internet Yes Yes Download only
Air-gap friendly No No Yes
Official Microsoft support Yes Community Yes
Best for Production servers Dev/test setups Restricted environments

Congratulations! You have successfully installed PowerShell. Thanks for using this tutorial for installing Microsoft PowerShell on your Rocky Linux 10 system. For additional help or useful information, we recommend you check the official PowerShell website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a dedicated and highly skilled Linux Systems Administrator with over a decade of progressive experience in designing, deploying, and maintaining enterprise-grade Linux infrastructure. His professional journey began in the telecommunications industry, where early exposure to Unix-based operating systems ignited a deep and enduring passion for open-source technologies and server administration.​ Throughout his career, r00t has demonstrated exceptional proficiency in managing large-scale Linux environments, overseeing more than 300 servers across development, staging, and production platforms while consistently achieving 99.9% system uptime. He holds advanced competencies in Red Hat Enterprise Linux (RHEL), Debian, and Ubuntu distributions, complemented by hands-on expertise in automation tools such as Ansible, Terraform, Bash scripting, and Python.
Back to top button