Skip confirmation while using Install-Package?

江枫思渺然 提交于 2019-12-10 10:37:34

问题


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?


回答1:


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.




回答2:


choco feature enable -n allowGlobalConfirmation

will suppress license and other prompts during install.

Set-PackageSource -Name chocolatey -Trusted

will set package source as trusted.



来源:https://stackoverflow.com/questions/43566360/skip-confirmation-while-using-install-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!