A cross‑platform GitHub Action that installs a specific PowerShell Core version—or the latest stable release—on any GitHub‑hosted runner
(Linux, macOS, or Windows). The action automatically skips installation when the requested version is already present.
Prerelease versions (e.g. 7.6.0-preview.6, 7.5.0-rc.1) are also supported.
Add the action to a job in your workflow file:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PowerShell
uses: PSModule/install-powershell@v1
with:
Version: 7.5.0
- name: Run a PowerShell script
shell: pwsh
run: |
Write-Host "Using PowerShell $($PSVersionTable.PSVersion)" - name: Install PowerShell Preview
uses: PSModule/install-powershell@v1
with:
Version: 7.6.0-preview.6 - name: Install latest PowerShell Preview
uses: PSModule/install-powershell@v1
with:
Prerelease: true| Input | Required | Default | Description |
|---|---|---|---|
Version |
false |
latest |
Desired PowerShell Core version (e.g. 7.4.1, 7.6.0-preview.6). Use latest to install the newest stable release (or newest prerelease when Prerelease is true). |
Prerelease |
false |
false |
Install a prerelease version. When true and Version is latest, resolves to the latest prerelease. Similar to -Prerelease on Install-PSResource. |
This action does not require any secrets.
This action does not generate any outputs.
-
Version resolution If
Versionis set tolatest(case‑insensitive), the action queries the GitHub API for the newest stable release tag in thePowerShell/PowerShellrepository and substitutes that version. WhenPrereleaseistrue, it queries for the latest prerelease instead. Explicit prerelease version strings (e.g.7.6.0-preview.6) are passed through directly. -
Skip logic Before installing, the action checks the current runner to see whether the requested version is already available (
pwsh -Command $($PSVersionTable.PSVersion)). If it matches, the step ends immediately. -
Platform‑specific installers
Runner OS Install strategy Linux (Debian/Ubuntu‑based) Uses APT if available; otherwise downloads the .debasset directly from the release page and installs withdpkg.macOS Prefers Homebrew Cask ( brew install --cask powershell) and falls back to downloading the.pkginstaller. ARCH detection (arm64/x64) is automatic.Windows Downloads the corresponding .msipackage and installs silently withmsiexec. -
Error handling The step fails with a clear error message if the requested version cannot be resolved or if the operating‑system distribution is unsupported (e.g., non‑APT Linux distros).