PowerShellGet version 1.5.0 has added support for module publishers to require explicit license acceptance from users before installing a module. This feature has been requested by several of our partners, in order to meet their legal requirements.
If a user installs, updates, or saves a module using PowerShellGet, and the publisher of that module requires the user to agree to a license, the user must indicate they accept the license or the operation fails. This works whether the module is installed directly or if it is installed because it is a dependency for another module.
Publishing Requirements for Modules
Publishers that would like to require license acceptance for their modules should fulfil the following requirements:
- Set RequireLicenseAcceptance = $True in PSData section of module manifest.
- Add license.txt in root directory of module.
- Include License Uri in module manifest.
Install-Module, Save-Module, Update-Module
The PowerShellGet commands Install-Module, Save-Module, and Update-Module have all been modified to support license acceptance. When run, the command will show the license terms from license.txt and prompt the user to accept the license. Module will be delivered to the user system only if the user accepts the license terms. An example using Install-Module is shown below:
Install-Module, Save-Module, and Update-Module support a new parameter -AcceptLicense. This enables scripting, as users will not be prompted if -AcceptLicense is specified. Users who specify this flag are accepting all license terms for all modules that are installed when their command is run, including modules that are installed as dependencies.
Specifying -Force is NOT sufficient to accept a license. -AcceptLicense is required for permission to install. If -Force is specified and -AcceptLicense is not specified and license acceptance is required, the operation will fail.
Scripts Cannot Require License Acceptance
License Acceptance is not available for publishers to use with scripts. The feature requires a separate license.txt file, and scripts are published as single files. However, the scenario where a script depends on a module that requires license acceptance is supported. Save-Script, Install-Script, Update-Script will show license.txt for dependent modules(that require license acceptance) and prompt user to accept the license. They also support -AcceptLicense parameter.
The documentation for this feature is included in the PowerShellGet documentation.
PowerShell Community and Tools