PowerShell for Linux, Without Sudo

getpw: A lightweight, strictly POSIX /bin/sh installer for PowerShell.

Overview

What is this?

A simple, zero-sudo PowerShell installer for Linux systems powered by a single POSIX-compliant /bin/sh script.

Why?

As an avid PowerShell user on both Linux and Windows machines, I wanted to provide Linux users with a frictionless, simple way to try and install PowerShell on their systems without requiring root privileges or package manager overhead.

All binaries are downloaded directly from official PowerShell GitHub Releases.

Quickstart

Install latest release:

curl -fsSL https://leblocks.github.io/getpw/sh | sh

Install a specific version:

curl -fsSL https://leblocks.github.io/getpw/sh | sh -s -- 7.4.6

Alternative with wget:

wget -qO- https://leblocks.github.io/getpw/sh | sh

Quick Docker Tests (installs and drops directly into pwsh):

Alpine:

docker run --rm -it alpine:3.23 sh -c "apk add --no-cache icu-libs libstdc++ && wget -qO- https://leblocks.github.io/getpw/sh | sh && ~/pwsh/current/pwsh"

Debian:

docker run --rm -it debian:bookworm-slim sh -c "apt-get update -qq && apt-get install -y -qq curl ca-certificates libicu72 && curl -fsSL https://leblocks.github.io/getpw/sh | sh && ~/pwsh/current/pwsh"

Ubuntu:

docker run --rm -it ubuntu:24.04 sh -c "apt-get update -qq && apt-get install -y -qq curl ca-certificates libicu74 && curl -fsSL https://leblocks.github.io/getpw/sh | sh && ~/pwsh/current/pwsh"

Features

  • Zero-Sudo Execution: Installs entirely inside ${HOME}/pwsh/<version> without needing root or modifying system-level directories.
  • Active Symlink: Automatically configures ${HOME}/pwsh/current pointing to the active installation.
  • Strict POSIX /bin/sh: Zero bashisms. Verified with shellcheck -s sh and tested across ash (Alpine), dash (Debian), and bash (Ubuntu).
  • Architecture & Libc Detection: Automatically selects the correct official release asset for:
    • glibc + x64
    • glibc + arm64
    • musl + x64
    • musl + arm64
  • Idempotency & Safety:
    • Skips re-downloading and exits cleanly if already installed and active.
    • Preserves current link and displays manual switch command if another version is active.
    • Atomic moves and cleanup traps prevent broken directories on failures.

Post-Install Usage

Running PowerShell directly:

~/pwsh/current/pwsh

Adding to PATH (~/.bashrc, ~/.zshrc, or ~/.profile):

export PATH="$HOME/pwsh/current:$PATH"

Set as Default Login Shell (Optional, requires sudo):

sudo sh -c 'grep -qxF "$HOME/pwsh/current/pwsh" /etc/shells || echo "$HOME/pwsh/current/pwsh" >> /etc/shells'
chsh -s "$HOME/pwsh/current/pwsh"

Disclosures

AI Disclosure: AI assistance was utilized in designing, authoring, and verifying this project.