The CmdletBinding attribute

The CmdletBinding attribute is used to turn a function into an advanced function. Advanced functions were introduced with PowerShell 2.

CmdletBinding may be used to do the following:

  • Access common parameters, such as ErrorAction, Verbose, and Debug
  • Gain access to the built-in pscmdlet variable
  • Declare support for WhatIf and Confirm and define the impact level of the command

If a script or function has no parameters, and wishes to make use of the capabilities of CmdletBinding, an empty param block must be declared:

function Test-EmptyParam {
[CmdletBinding()]
param ( )
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.77.71