Pcornel
Automation · PowerShell Automation

Parameters

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

Back to the Topic

Answer

PowerShell parameters are declared in param() with types, Mandatory, defaults and validation such as ValidateSet or ValidatePattern, so bad input fails before the script acts.

Remember

  • Parameters have types, Mandatory and defaults.
  • ValidateSet, ValidatePattern and ValidateRange reject bad input.
  • Parameters can take pipeline input.

First checks

  • Get-Help <script> -Parameter * — parameter docs
  • param() with [Parameter(Mandatory)] and validation attributes — validation
  • Pipeline input support — design

Verify in this order

caller → param block → validated values

Where it usually breaks

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

Parameters · PowerShell operational reference

BoundaryParameters 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=5237

Confirmation

Confirm action

Continue?