PowerShell (known as pwsh in its cross-platform version, PowerShell 7+) is Microsoft’s open-source shell and scripting language.
Installing it on Linux allows you to run PowerShell scripts, cmdlets, and modules alongside native Linux tools.

We’ll use WSL (Windows Subsystem for Linux) — with Ubuntu 24.04 LTS — as the main example, though the process is similar on other distros.


🧩 Prerequisites

  • WSL Installed:
    Ensure WSL is set up (Windows 10 2004+ or Windows 11).
    To install WSL, open PowerShell as Administrator and run:

    wsl --install

    This installs Ubuntu by default. After reboot, open Ubuntu and update your packages:

    sudo apt update && sudo apt upgrade -y
  • Internet Access: Required for downloading packages.

  • Admin Rights: Use sudo for administrative tasks.

  • WSL 2 Recommended: Check or set version:

    wsl -l -v
    wsl --set-version <distro> 2


⚙️ Installing PowerShell in WSL (Ubuntu)

1. Launch Your WSL Distribution

Open Windows Terminal or search Ubuntu in the Start menu to start your WSL session.

2. Update Package Lists

sudo apt update && sudo apt upgrade -y

3. Add Microsoft’s GPG Signing Key

curl https://packages.microsoft.com/keys/microsoft.asc | \
  sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null

This imports Microsoft’s trusted signing key.

4. Add Microsoft Repository

PowerShell packages are hosted on Microsoft’s official repositories.
Use the command below — it dynamically uses your Ubuntu $VERSION_ID:

sudo curl -o /etc/apt/sources.list.d/microsoft-prod.list \
  https://packages.microsoft.com/config/ubuntu/$VERSION_ID/prod.list

If your version (like Ubuntu 25.10) isn’t yet available, manually download from GitHub:

wget https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell_7.5.4-1.deb_amd64.deb
sudo dpkg -i powershell_7.5.4-1.deb_amd64.deb
sudo apt-get install -f

For unsupported releases, use a fallback (e.g., Ubuntu 24.04 repository):

sudo curl -o /etc/apt/sources.list.d/microsoft-prod.list \
  https://packages.microsoft.com/config/ubuntu/24.04/prod.list
sudo apt-get install -f

5. Update Package Lists Again

sudo apt update

6. Install PowerShell

sudo apt install -y powershell

The installation downloads ~150–200 MB and installs the latest stable PowerShell (7.5+ as of Oct 2025).

7. Verify Installation

pwsh --version

Example output: PowerShell 7.5.4

Launch PowerShell:

pwsh

Check detailed version info:

$PSVersionTable

You’ll see output like:

PSVersion 7.5.4 PSEdition Core OS Ubuntu 24.04.3 LTS Platform Unix

Exit PowerShell anytime with:

exit


⚡ Optional: Set PowerShell as Default Shell

Launch PowerShell automatically when WSL starts:

echo '/usr/bin/pwsh' | sudo tee -a /etc/passwd

Or start WSL directly into PowerShell from Windows:

wsl --exec pwsh


🔄 Post-Installation Tips

  1. Update PowerShell regularly:

    sudo apt update && sudo apt upgrade -y

  2. Install .NET SDK (optional):

    sudo apt install -y dotnet-sdk-8.0

  3. Access Windows Files from WSL PowerShell:

    cd /mnt/c/Users
    notepad.exe

  4. Uninstall PowerShell:

    sudo apt remove --purge powershell && sudo apt autoremove


🧰 Troubleshooting

GPG Key Error:
Re-run the key import:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

404 Repo Error:
Ensure your Ubuntu version matches:

lsb_release -a

WSL Issues:
Restart your subsystem:

wsl --shutdown


🚀 Performance Notes

PowerShell runs natively inside WSL, with near-native speed under WSL 2.
For large automation scripts or CI/CD jobs, always use:

wsl --set-default-version 2


🐧 Other Linux Distributions

Distro Installation Summary
Debian Use https://packages.microsoft.com/config/debian/12/prod.list
Fedora / RHEL / CentOS
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc<br>sudo dnf install https://packages.microsoft.com/yumrepos/microsoft-rhel7.0-fedora.32-x64.rpm<br>sudo dnf install powershell
Arch Linux
yay -S powershell-bin
(AUR) or download manually
openSUSE
sudo zypper ar -f https://packages.microsoft.com/yumrepos/microsoft-rhel7.0-opensuse.15-x64.rpm<br>sudo zypper install powershell

For full details, see the official Microsoft docs:
👉 Install PowerShell on Linux


With this setup, you’ll have a fully functional PowerShell environment inside WSL — perfect for scripting, automation, and managing cross-platform workflows.