Preference variable $ConfirmPreference allows getting more or less PowerShell confirmation prompts
Posted by jpluimers on 2021/05/04
On my list to experiment with are [Wayback] about_Preference_Variables – PowerShell | Microsoft Docs, especially
$ConfirmPreference
Determines whether PowerShell automatically prompts you for confirmation before running a cmdlet or function.
The
$ConfirmPreference
variable’s valid values are High, Medium, or Low. Cmdlets and functions are assigned a risk of High, Medium, or Low. When the value of the$ConfirmPreference
variable is less than or equal to the risk assigned to a cmdlet or function, PowerShell automatically prompts you for confirmation before running the cmdlet or function.If the value of the
$ConfirmPreference
variable is None, PowerShell never automatically prompts you before running a cmdlet or function.To change the confirming behavior for all cmdlets and functions in the session, change
$ConfirmPreference
variable’s value.To override the
$ConfirmPreference
for a single command, use a cmdlet’s or function’s Confirm parameter. To request confirmation, use-Confirm
. To suppress confirmation, use-Confirm:$false
.Valid values of
$ConfirmPreference
:
- None: PowerShell doesn’t prompt automatically. To request confirmation of a particular command, use the Confirm parameter of the cmdlet or function.
- Low: PowerShell prompts for confirmation before running cmdlets or functions with a low, medium, or high risk.
- Medium: PowerShell prompts for confirmation before running cmdlets or functions with a medium, or high risk.
- High: PowerShell prompts for confirmation before running cmdlets or functions with a high risk.
–jeroen
Leave a Reply