Search notes:

PowerShell: Annotating a function with CmdletBinding

A function with cmdlet binding automatically defines the common parameters -errorAction etc.

Influence on write-verbose

One effect of annotating a function with [CmdletBinding()] is that the write-verbose cmdlet is enabled.
In the following example, the invocation of wv-with … -verbose prints the value of $p while the invocation of wv-without … -verbose does not have (any visible, at least) effect:
function wv-with {

   [cmdletBinding()]
    param($p)

    write-verbose "param is $p"
}

function wv-without {

    param($p)

    write-verbose "param is $p"
}

wv-with     XYZ
wv-with     XYZ -verbose

wv-without  XYZ
wv-without  XYZ -verbose
Github repository about-PowerShell, path: /language/function/cmdletBinding/write-verbose.ps1

See also

System.Management.Automation.CmdletBindingAttribute

Index