Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Advanced Functions

Direct answer

Advanced functions use [CmdletBinding()] and param() with validation attributes, pipeline input, -WhatIf and -Confirm support and verbose output, behaving like compiled cmdlets.

When to use this

Use this when writing PowerShell functions that behave like cmdlets.

First 30 seconds

1. Advanced functions behave like cmdlets: [CmdletBinding()], common parameters, ShouldProcess.

2. Support -WhatIf for changes.

3. Pipeline input.

4. Write-Verbose for details.

5. Return objects.

Operational verification

[CmdletBinding()] → common params + ShouldProcess → actions

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 writing PowerShell functions that behave like cmdlets.
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 the command with Get-Command to show CmdletBinding, common parameters and parameter sets. Test direct and pipeline invocations, -WhatIf/-Confirm paths if supported, plus terminating and non-terminating failure cases. Verify target state after a real mutation because ShouldProcess only controls whether the function chooses to attempt it.

Step 2 Common mistakes Narrow the fault
  • Missing SupportsShouldProcess on functions that change things.
Step 3 Where it fails Narrow the fault

SupportsShouldProcess is not evidence that every mutation is protected; the implementation must invoke ShouldProcess. Common-parameter availability does not make a function idempotent or transaction-safe. Separate the advanced-function interface, lifecycle block behavior, side-effect gating and final target-evidence of the actual state.

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
  • [CmdletBinding()] adds common parameters.
  • SupportsShouldProcess enables -WhatIf/-Confirm.
  • Validation attributes reject bad input.
Key checks
  • CmdletBinding(SupportsShouldProcess) — -WhatIf/-Confirm
  • begin/process/end blocks — pipeline
  • Get-Help <function> -Full — help
ReferenceWhy it matters1 section · depth on demand

In depth

Advanced functions use [CmdletBinding()] to behave like compiled cmdlets: they get common parameters (-Verbose, -ErrorAction, -WhatIf, -Confirm), pipeline processing blocks, and ShouldProcess support for safe changes.

function Set-PortDescription {
  [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
  param(
    [Parameter(Mandatory, ValueFromPipelineByPropertyName)][string]$Switch,
    [Parameter(Mandatory, ValueFromPipelineByPropertyName)][string]$Port,
    [Parameter(Mandatory, ValueFromPipelineByPropertyName)][string]$Description
  )
  process {
    if ($PSCmdlet.ShouldProcess("$Switch $Port", "set description '$Description'")) {
      Write-Verbose "Updating $Switch $Port"
      # API/SSH call here
    }
  }
}
Import-Csv ports.csv | Set-PortDescription -WhatIf

The process block runs once per piped object, so the function works equally for one port or thousands from a CSV.

ReferenceImportant terms & boundaries1 section · depth on demand

PowerShell mechanics

Advanced functions use [CmdletBinding()] and parameter metadata so script functions participate in cmdlet-like semantics such as common parameters, parameter sets and $PSCmdlet. begin, process, end and clean provide lifecycle hooks for pipeline processing. SupportsShouldProcess enables the ShouldProcess() contract used by -WhatIf and -Confirm when the function author actually gates mutations through it.

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

Use advanced functions for reusable automation where a stable command contract matters. Keep side effects behind ShouldProcess when appropriate, emit structured objects, use verbose/error streams for diagnostics, and declare pipeline binding intentionally. Avoid turning every helper into an advanced function; choose it when cmdlet semantics materially improve the interface.

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 Advanced Functions

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

function Set-DemoState { [CmdletBinding(SupportsShouldProcess)] param([string]$Name) if ($PSCmdlet.ShouldProcess($Name,"Update")) { [pscustomobject]@{Name=$Name;Changed=$true} } }
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_functions_advanced?view=powershell-7.5 · confidence 94%
Embedded reference data

Quick lookup tables

Advanced Functions · PowerShell operational reference

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

BoundaryAdvanced Functions 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

Advanced functions can still emit accidental success-stream objects, and common parameters affect engine behavior rather than business success. Write-Error behavior depends on terminating semantics, while $PSCmdlet.ThrowTerminatingError() creates a different control-flow boundary. Capture ErrorRecord details and structured function output separately.

Confirmation

Confirm action

Continue?