Launch Python utilities from PowerShell with explicit paths, arguments, and exit-code checks.
Sheet: 24 of 25 | Platform: Windows 10/11 | Shell: PowerShell 7.x and Windows PowerShell 5.1 (unless marked otherwise) | Editorial review: November 24, 2026
Examples use the MGU project root and illustrative staging, backup, and download paths. Replace them with existing, approved paths as needed. Unless explicitly marked as a continuation, examples are independent. Read commands before running them; commands that write or modify files can change existing data.
Quick commands
1. Locate Python launchers
Get-Command python, py -ErrorAction SilentlyContinue
2. Check the installed Python version
python --version
3. Run a script from a known working directory
Set-Location -LiteralPath 'C:\MGU'
python 'C:\MGU\tools\audit.py'
4. Pass quoted paths and flags to a script
python 'C:\MGU\tools\audit.py' --scan 'C:\MGU\library'
5. Check a script's exit status immediately
python 'C:\MGU\tools\audit.py'
if ($LASTEXITCODE -ne 0) { throw "Python exited with code $LASTEXITCODE" }
6. Run a script with a virtual-environment interpreter
& 'C:\MGU\tools\.venv\Scripts\python.exe' 'C:\MGU\tools\audit.py'
7. Inspect script-specific options when supported
python 'C:\MGU\tools\audit.py' --help
Operational notes
Python and the example script must exist first; audit.py and --scan are illustrative, not built-in. Use the script's documented options. A zero exit code means the program reported success, not necessarily zero discrepancies. Keep working directory and interpreter explicit.