CmdletBinding attribute
The CmdletBinding attribute is a PowerShell declaration that enables cmdlet-like behavior and advanced features for a script or function.
Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
The CmdletBinding attribute is a PowerShell function attribute that enables cmdlet-like features, including common parameters and advanced parameter behavior.
- How it is used
- Builds PowerShell functions that behave more like cmdlets and support common parameters, pipeline input, validation, and safety prompts.
- How deep it goes
- Explains implementation through function comparisons and examples, then defers deeper parameter sets and dynamic parameters.
- Examples
- Uses Get-MachineInfo to demonstrate help, common parameters, direct and pipeline invocation, and safe system-changing operations.
- What you can do after
- Build it from scratch as an advanced function with common parameters, pipeline processing, and optional WhatIf or Confirm support.
Practical Automation with PowerShell: Effective scripting from the console to the cloud
The CmdletBinding attribute enables advanced PowerShell function behavior, including common parameters such as verbose output and error handling.
- How it is used
- Establishes advanced-function behavior for reusable PowerShell functions and scripts, including verbose output and error handling.
- How deep it goes
- Explains attribute placement and practical benefits but defers detailed mechanics of advanced-function behavior.
- Examples
- Demonstrates CmdletBinding in Set-ArchiveFilePath and a log-file archive-and-delete script.
- What you can do after
- Apply it via PowerShell by adding CmdletBinding to reusable functions and scripts before output and parameter declarations.
Related concepts
- functionconfigures · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- advanced functionconfigures · An advanced function is a PowerShell function that provides cmdlet-like behavior through features such as advanced parameter binding, common parameters, pipeline support, validation, and confirmation.
- param blockpart of · A parameter block is a PowerShell construct that declares a script or function’s parameters, default values, and related metadata.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

