toolbox · language

PowerShell

The Windows shell every command in this project runs in.

Install

winget install --id Microsoft.PowerShell --source winget
$PSVersionTable.PSVersion

What it is

PowerShell is a shell and scripting language for Windows (and also Linux and macOS). Windows ships Windows PowerShell 5.1; the modern cross-platform version is PowerShell 7 (pwsh).

How it works

  • Commands are cmdlets named Verb-Noun, such as Get-ChildItem or Set-Content.
  • The pipeline passes objects, not just text: Get-ChildItem | Measure-Object Length -Sum works on real file objects.
  • Variables start with $, strings interpolate like "$env:USERPROFILE\file", and scripts end in .ps1.
  • Execution policy controls whether scripts may run. We use the explicit form pwsh -NoProfile -File ./script.ps1.

In this project

Every build and check command is PowerShell-safe: no bash-only syntax, no backslash line continuations. scripts/scrub-check.ps1 is the secret scanner, and the CI workflow runs it with shell: pwsh.

Gotchas

  • Windows PowerShell 5.1 and PowerShell 7 are different programs. Check $PSVersionTable.PSVersion.
  • && works in PowerShell 7 but not 5.1. Use ; or separate lines when in doubt.
  • Backtick is the line-continuation character, and a trailing space after it breaks the command.