简体   繁体   中英

Skip confirmation while using Install-Package?

I have added ChocolateyGet as a provider on Powershell so I can use it with PackageManagement (OneGet), it works but every package I try to install warns:

https://www.chocolatey.org is not a trusted package source

Then asks for confirmation. It also asks me if I agree to the license of the package.

I wanted to make a script to automatically install some packages, but I needed this script to be unattended, and it's not possible now because it asks those two previous questions.

Is there anyway to circumvent/automatically respond these confirmations? Like the y or yes command on Linux?

You need to use -Force where there is a Force property available on any cmdlets, otherwise if there isn't but there is a confirm, you are able to use -Confirm:$False which acts the same as pressing Yes.

Be careful using this however as if you in fact didn't want to process the action...you don't get a second chance.

choco feature enable -n allowGlobalConfirmation

will suppress license and other prompts during install.

Set-PackageSource -Name chocolatey -Trusted

will set package source as trusted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM