Pcornel
Windows

PowerShell

Cheat sheet · https://pcornel.dk/topic.php?topic=371

Back to the Topic

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 version
  • Get-Command <name> — which cmdlet/function/exe runs
  • Get-Help <cmdlet> -Full — syntax and parameters
  • Get-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

ItemMeaningEvidence boundary
Windows PowerShell 5.1Inbox Windows productpowershell.exe; .NET Framework; Windows lifecycle
PowerShell 7Separate modern productpwsh.exe; modern .NET; own lifecycle
PipelineObject transport between commandssuccessfully receiving an object does not prove downstream state
ModuleCommand packaging/discovery boundaryimport/discovery does not prove target operation success
RemotingRemote execution frameworktransport 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

Confirmation

Confirm action

Continue?