Suppress Confirmation

by Mar 11, 2015

All PowerShell Versions

Some cmdlets (like Remove-ADGroupMember) automatically ask for confirmation. This can be a problem in scripts running unattended.

To suppress unwanted confirmation dialogs, explicitly set the -Confirm switch parameter to false:

Remove-ADGroupMember -Identity 'Domain Admins' -Members user12 -Confirm:$false

Alternatively, you can change the risk level at which PowerShell will automatically ask for confirmation. This line turns automatic confirmation off for all cmdlets:

$ConfirmPreference = 'None'

Note that both tips apply to default confirmation dialogs only. If a cmdlet decides to ask for confirmation outside the default PowerShell confirmation architecture, you need to consult the cmdlet documentation to find out how to suppress those.

Twitter This Tip! ReTweet this Tip!