Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Parameters · PowerShell Automation

Direct 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.

When to use this

Use this when declaring PowerShell parameters.

First 30 seconds

1. Parameters with types and validation ([ValidateSet], [ValidatePattern], [ValidateRange]).

2. Mandatory where required.

3. Default values safe.

4. Parameter sets for alternative usage.

5. Document with help.

Operational verification

caller → param block → validated values

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
PowerShell 7.5/current
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPowerShell 7.5/current · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when declaring PowerShell parameters.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Inspect parameter sets with (Get-Command <name>).ParameterSets and Get-Help <name> -Full. Test each supported parameter set, invalid values and pipeline-binding paths. For an unexpected invocation, capture InvocationInfo.BoundParameters or equivalent diagnostic context to show what the binder selected.

Step 2 Common mistakes Narrow the fault
  • Parameters without validation attributes.
Step 3 Where it fails Narrow the fault

Do not confuse a syntactically accepted invocation with correct intent. Parameter-set ambiguity, implicit conversion, wildcard support and pipeline binding can all select behavior different from what the caller assumed. Separate binder decisions from command execution and target-state outcome.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Parameters have types, Mandatory and defaults.
  • ValidateSet, ValidatePattern and ValidateRange reject bad input.
  • Parameters can take pipeline input.
Key checks
  • Get-Help <script> -Parameter * — parameter docs
  • param() with [Parameter(Mandatory)] and validation attributes — validation
  • Pipeline input support — design
ReferenceWhy it matters1 section · depth on demand

In depth

PowerShell parameters provide built-in validation, mandatory prompts, pipeline input and tab completion — much more than positional arguments in other shells. Declaring them carefully makes scripts both safer and easier to use.

AttributePurpose
[Parameter(Mandatory)]Required
[ValidateSet('test','prod')]Allowed values (and tab completion)
[ValidatePattern('^SW-\d+$')]Regex check
[ValidateRange(1,64)]Numeric range
[ValidateScript({ Test-Path $_ })]Custom check
ValueFromPipelineAccept piped objects
[switch]On/off flag
Parameter setsMutually exclusive groups of options

Validation failures stop the script before it does anything, with a message naming the parameter — exactly where invalid input should be caught.

ReferenceImportant terms & boundaries1 section · depth on demand

PowerShell mechanics

PowerShell parameter binding selects a parameter set and associates supplied arguments or pipeline input with parameters using names, positions, types, validation attributes and conversion rules. Pipeline binding can occur by value and by property name. Splatting changes call syntax but still feeds the same binder, while default values and dynamic parameters can make the effective contract context dependent.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Authoring and lifecycle

Define parameter types and validation where they clarify the contract, use parameter sets for genuinely distinct invocation modes, and avoid ambiguous positional interfaces in automation. Treat defaults as behavior that must be versioned and tested. When forwarding parameters through wrappers, prefer deliberate splatting and remove wrapper-only keys before invoking downstream commands.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

PowerShell 7.5/current 7.5/currentMinimal authored PowerShell pattern for Parameters

Assumptions: Review target identity, permissions and environment before mutation.

param([Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$Path)
Get-Item -LiteralPath $Path
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPowerShell 7.5/current 7.5/current

Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parameters?view=powershell-7.5 · confidence 94%
Embedded reference data

Quick lookup tables

Parameters · PowerShell operational reference

Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.

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
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Binding errors can occur before the command body executes. Successful conversion can still alter meaning—for example string-to-enum or collection coercion—so verify resulting values inside the command when ambiguity matters. Pipeline by-property-name depends on property names and compatible types, not visual column headings.

Confirmation

Confirm action

Continue?