Automation · PowerShell Automation
Scripts
Cheat sheet · https://pcornel.dk/topic.php?topic=5236
Answer
PowerShell scripts are .ps1 files with parameters, functions and logic. Sign them or set an execution policy like RemoteSigned, and use #Requires to declare needed modules and versions.
Remember
- #Requires declares needed modules and versions.
- Execution policy controls which scripts run.
- Signing scripts proves origin.
First checks
Invoke-ScriptAnalyzer -Path script.ps1— lintGet-AuthenticodeSignature script.ps1— signatureGet-ExecutionPolicy -List— policy
Verify in this order
script.ps1 → engine → actions
Where it usually breaks
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
Scripts · PowerShell operational reference
| Boundary | Scripts reference |
|---|---|
| Runtime identity | PowerShell edition/version + command/module source |
| Persistent intent | Script/module/config prerequisites under source control |
| Verification | Read-only discovery → execution evidence → independent target read-back |
| Output contract | Structured objects/streams before formatting |
| Failure boundary | Separate engine/binding from transport/API/native and target-state failures |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5236