My Technical Notes

Wednesday, 8 February 2017

PowerShell: Getting a Function's `ConfirmImpact` from within it

The following `Test-Function` gets the `ConfirmImpact` of a function within itself:

Function Test-Function { 
    [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="Medium")] 


The only caveat is that the above code assumes that there is only one attribute of type `System.Management.Automation.CmdletBindingAttribute` (or its basetype `CmdletCommonMetadataAttribute` in the same namespace).

No comments: