要求接受脚本的许可证

脚本不支持许可证接受。 但是,支持脚本依赖于需要接受许可证的模块的方案。

PowerShellGet 脚本命令支持参数 AcceptLicense ,该参数的行为就像用户看到许可证一样。 如果未指定 AcceptLicense ,则会向用户显示 license.txt 依赖模块的文件,并提示用户接受许可证。

例子

示例 1:安装具有需要接受许可证的依赖项的脚本

脚本“ScriptRequireLicenseAcceptance”依赖于模块“ModuleRequireLicenseAcceptance”。 系统将提示用户接受许可证。

PS> Install-Script -Name ScriptRequireLicenseAcceptance

License Acceptance
MIT License 2.0
Copyright (c) 2016 PowerShell Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.

Do you accept the license terms for module 'ModuleRequireLicenseAcceptance'.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

示例 2:安装具有需要许可证接受和 -AcceptLicense 的依赖项的脚本

脚本“ScriptRequireLicenseAcceptance”依赖于模块“ModuleRequireLicenseAcceptance”。 指定 -AcceptLicense 不会提示用户接受许可证。

PS> Install-Script -Name ScriptRequireLicenseAcceptance -AcceptLicense

更多详细信息