Advanced Functions: `[CmdletBinding()]`

One line, [CmdletBinding()] above param(), turns a function into an advanced function that binds its parameters the way a cmdlet does: it refuses a misspelled parameter instead of quietly ignoring it, and gets -Verbose, -ErrorAction and the other common parameters for free.

Updated

Cheat sheet for the lesson Advanced Functions: `[CmdletBinding()]`: One line, [CmdletBinding()] above param(), turns a function into an advanced function that binds its parameters the way a cmdlet does: it refuses a misspelled parameter instead of quietly ignoring it, and gets -Verbose…
Category
PowerShell
Level
Journeyman
Tags
advanced-function, cmdletbinding, common-parameters, erroraction, powershell