This repository contains ps-update.ps1, a Windows PowerShell script that checks for the latest stable PowerShell 7 release on GitHub and installs it if a newer version is available. This does not update PowerShell 5.
- Detects the current session PowerShell version.
- Tries to detect the installed
pwshversion from PATH. - Calls the GitHub API for the latest stable release:
https://api.github.com/repos/PowerShell/PowerShell/releases/latest
- Parses and validates the release version.
- Skips update when:
- the latest major version is less than 7, or
- the installed
pwshversion is already up to date.
- Selects the matching Windows MSI installer asset for your OS architecture (
x64,arm64, etc.). - Downloads the MSI to the temp folder.
- Runs a passive MSI install (
msiexec /i ... /passive /norestart). - Re-checks and prints the installed
pwshversion after installation.
- The script uses
$ErrorActionPreference = 'Stop'and throws on critical failures. - If
pwshis not immediately found after install, restarting the terminal/session may be required.