Users Requesting Confirmation
When you specify a value of true
for the SupportsShouldProcess
parameter of the Cmdlet attribute
declaration, the Confirm parameter is added to the parameters of the cmdlet.
In the default environment, users can specify the Confirm parameter or "-Confirm:$true
so that
confirmation is requested when the ShouldProcess()
method is called. This forces confirmation
regardless of the impact level setting.
If Confirm parameter is not used, the ShouldProcess()
call requests confirmation if the
$ConfirmPreference
preference variable is equal to or greater than the ConfirmImpact
setting of
the cmdlet or provider. The default setting of $ConfirmPreference
is High. Therefore, in the
default environment, only cmdlets and providers that specify a high-impact action request
confirmation.
If Confirm is explicitly set to false (-Confirm:$false
), the cmdlet runs without prompting for
confirmation and the $ConfirmPreference
shell variable is ignored.
Remarks
For cmdlets and providers that specify
SupportsShouldProcess
, but notConfirmImpact
, those actions are handled as "medium impact" actions, and they will not prompt by default. Their impact level is less than the default setting of the$ConfirmPreference
preference variable.If the user specifies the
Verbose
parameter, they will be notified of the operation even if they are not prompted for confirmation.