2010-12-16 10:09 AM
The following commands require that a user confirm the operation before continuing...
I would like to be able to answer "yes" programmatically for these commands so the user is not prompted for each item. Is that possible?
I see that each of these cmdlets have a -Confirm switch, but they seem to behave the same weather the switch is set or not.
2010-12-16 11:30 AM
Yes, the simplest way to do this is to use the $confirmpreference environment variable. To turn off prompts completely, add the following to the top of your script:
$confirmpreference = "none"
2010-12-16 01:24 PM
Thanks for the great suggestions. I tried using -Confirm $false, but that didn't work...I was missing the colon syntax, -Confirm:$false works great.
I'm curious why that option defaults to $true? I understand the reasoning from an administrative perspective...those are dangerous commands. From from a programming perspective, if the default is $true, maybe there should be -NoConfirm switch to change it to false?
Thanks again for the help!