Pcornel
Automation

PowerShell Automation

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

Back to the Topic

Answer

PowerShell automation uses cmdlets, pipelines of objects, functions, modules and remoting to manage Windows, Active Directory, Microsoft 365, Azure, VMware and more from scripts that run on Windows, Linux and macOS.

Remember

  • PowerShell passes objects, not text.
  • Use -WhatIf before bulk changes.
  • Set $ErrorActionPreference = 'Stop' so try/catch works.

First checks

  • $PSVersionTable — PowerShell version/edition
  • Invoke-ScriptAnalyzer -Path . -Recurse — lint
  • Invoke-Pester — tests

Verify in this order

script → cmdlets/objects → remoting → targets

Where it usually breaks

Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.

PowerShell Automation · PowerShell operational reference

BoundaryPowerShell Automation reference
Runtime identityPowerShell edition/version + command/module source
Persistent intentScript/module/config prerequisites under source control
VerificationRead-only discovery → execution evidence → independent target read-back
Output contractStructured objects/streams before formatting
Failure boundarySeparate 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=5228

Confirmation

Confirm action

Continue?