Your First PowerShell Script: .ps1, Ways to Run It, #Requires, Comment-Based Help and pwsh vs powershell.exe
Called from inside PowerShell, a script runs in the same process in its own scope; called with pwsh -File, it runs in a new process and reports its result through the exit code, and Write-Error alone does not change that code. With Test-BookstoreHealth.ps1, which checks the Bookstore API, we show &, dot-sourcing, -File vs -Command, the shebang on Linux, #Requires, comment-based help, the differences between Windows PowerShell 5.1 and 7.6 LTS, and the BOM and CRLF traps.
15 Nov 2026
·
16 min
·
4