UseSupportsShouldProcess
Severity Level: Warning
Description
This rule discourages manual declaration of WhatIf
and Confirm
parameters in a function/cmdlet.
These parameters are, however, provided automatically when a function declares a CmdletBinding
attribute with SupportsShouldProcess
as its named argument. Using SupportsShouldProcess
not only
provides these parameters but also some generic functionality that allows the function/cmdlet
authors to provide the desired interactive experience while using the cmdlet.
Example
Wrong:
function foo {
param(
$param1,
$Confirm,
$WhatIf
)
}
Correct:
function foo {
[CmdletBinding(SupportsShouldProcess)]
param(
$param1
)
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for