PowerShell
Cheat sheet · https://pcornel.dk/topic.php?topic=371
Answer
PowerShell is an automation shell, scripting language and management framework built around .NET objects. On Windows, distinguish the inbox Windows PowerShell 5.1 product from modern PowerShell 7, which installs side-by-side as pwsh and has a separate support lifecycle.
Remember
- PowerShell pipelines normally pass .NET objects, not lines of text.
- Windows PowerShell 5.1 and PowerShell 7 are separate products and can coexist on Windows.
- Cmdlets follow a Verb-Noun naming model and emit typed objects that later commands can inspect or transform.
- Execution policy is a safety feature, not a security boundary.
- Remoting success depends on transport, authentication, endpoint/session configuration and authorization, not merely network reachability.
First checks
$PSVersionTable— PowerShell edition and versionGet-Command <name>— which cmdlet/function/exe runsGet-Help <cmdlet> -Full— syntax and parametersGet-ExecutionPolicy -List— execution policy per scope
Commands
Select-String -Path <file> -Pattern <text>- Searches files for a text or regular expression pattern, like grep or findstr.
$PSVersionTable- Read current PowerShell state for a bounded verification step.
Verify in this order
host and version → module loaded → command found → objects through the pipeline → output or error
Where it usually breaks
First mismatch in definition/configuration → security context → service/task/process creation → runtime state → output/side effect → event/performance evidence; preserve identity/native error/pre-state before mutation.
PowerShell reference map
| Item | Meaning | Evidence boundary |
|---|---|---|
| Windows PowerShell 5.1 | Inbox Windows product | powershell.exe; .NET Framework; Windows lifecycle |
| PowerShell 7 | Separate modern product | pwsh.exe; modern .NET; own lifecycle |
| Pipeline | Object transport between commands | successfully receiving an object does not prove downstream state |
| Module | Command packaging/discovery boundary | import/discovery does not prove target operation success |
| Remoting | Remote execution framework | transport reachability does not prove endpoint/authz/function |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=371