Search code examples
powershellpowershell-cmdlet

Create additional default parameters for cmdlet definitions


When you create a Powershell script or function, you are able to add the [CmdletBinding()] attribute in order to gain certain default parameters for use (e.g. -Verbose, -Debug, etc.) without having to define them yourself. In some cases you can add additional parameters to CmdletBinding, like SupportsShouldProcess or ConfirmImpact to further add additional supported parameters or change the cmdlet behavior.

Is it possible to define your own CmdletBindings for use within a module?


Solution

  • Is it possible to define your own CmdletBindings for use within a module?

    No

    Not in a script anyways :)

    The CmdletBinding attribute properties are processed by this method in the CommandMetadata API immediately prior to compilation of whatever scriptblock or function has it, so you'd have to rewrite parts of the language engine itself in order to modify its behavior.