Translate

Saturday, January 18, 2014

Avoiding the Confirm prompt in scripts

There are two ways you can suppress confirmation from a script or console:

1. Set the automatic variable to 'None' or 0 in your
 $ConfirmPreference = 'None'

cd Variable:
then dir to see all the variables currently defined in your shell, the text above will change the behavior though, and then at the end of your script you could change it back to 'High'

 2. Pass $false to the Cmdlet's -Confirm switch

 ... -confirm:$false


Windows PowerShell blog on this topic:  http://blogs.msdn.com/b/powershell/archive/2006/12/15/confirmpreference.aspx

Windows PowerShell blog home:  http://blogs.msdn.com/b/powershell/

No comments:

Post a Comment

Thanks for commenting, if you have a question and want a reply, please post it on TechNet forums and reference this blog, or navigate to www.SharePointPapa.com and post it there, all of these blog posts and more are on my SharePoint Papa site.

Popular Posts