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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758207861, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/function/cmdletBinding/index(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78