Wednesday, January 25, 2017

PowerShell's $ConfirmPreference

Some PowerShell cmdlets ask for confirmation before doing their work. (You can always ask for them to confirm by passing the -Confirm switch.) Clearly, different operations have different levels of possible damage, so it makes sense that PowerShell allows each cmdlet to declare a "confirm impact": None, Low, Medium, or High.

You can choose how impactful an operation should be before PowerShell prompts them for confirmation. The $ConfirmPreference variable can be set to one of those four values; confirmation will only be required for cmdlets with an impact higher than the preference.

To override the confirm preference to say "do not confirm this one action", pass -Confirm:$false.

Based on my Super User answer.

No comments:

Post a Comment