For things like -WhatIf, we have $PSCmdlet.ShouldProcess() given to us by the [CmdletBinding] attribute. Are there other such tools or practices for implementing common command line arguments such as -Verbose, -Debug, -PassThru, etc?
For things like -WhatIf, we have $PSCmdlet.ShouldProcess() given to us by the [CmdletBinding] attribute.
Share
Write-DebugandWrite-Verbosehandle the-Debugand-Verboseparameters automatically.-PassThruisn’t technically a common parameter, but you can implement it like:And this is an example of using your function’s PassThru value on a cmdlet:
Have a look at
Get-Help about_CommonParametersfor more information.