Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 1.13 KB

File metadata and controls

23 lines (18 loc) · 1.13 KB

PowerShell Update Script

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.

What the script does

  1. Detects the current session PowerShell version.
  2. Tries to detect the installed pwsh version from PATH.
  3. Calls the GitHub API for the latest stable release:
    • https://api.github.com/repos/PowerShell/PowerShell/releases/latest
  4. Parses and validates the release version.
  5. Skips update when:
    • the latest major version is less than 7, or
    • the installed pwsh version is already up to date.
  6. Selects the matching Windows MSI installer asset for your OS architecture (x64, arm64, etc.).
  7. Downloads the MSI to the temp folder.
  8. Runs a passive MSI install (msiexec /i ... /passive /norestart).
  9. Re-checks and prints the installed pwsh version after installation.

Notes

  • The script uses $ErrorActionPreference = 'Stop' and throws on critical failures.
  • If pwsh is not immediately found after install, restarting the terminal/session may be required.