Legal departments for some module publishers require that customers must explicitly accept the license before installing their module from PowerShell Gallery. If a user installs, updates, or saves a module using PowerShellGet, whether directly or as a dependency for another package, and that module requires the user to agree to a license, the user must indicate they accept the license or the operation fails.
Publish Requirements for ModulesModules that would like to require users to accept license should fulfill following requirements:
license.txt
, and prompted with: Do you accept these license terms (Yes/No/YesToAll/NoToAll)
.
Specifying âForce
is NOT sufficient to accept a license. âAcceptLicense
is required for permission to install. If âForce
is specified, RequiredLicenseAcceptance is True, and âAcceptLicense
is NOT specified, the operation fails.
Update-ModuleManifest -Path C:\modulemanifest.psd1 -RequireLicenseAcceptance -PrivateData @{
PSData = @{
# Flag to indicate whether the module requires explicit user acceptance
RequireLicenseAcceptance = $true
} # End of PSData hashtable
} # End of PrivateData hashtable
This command updates the manifest file and sets the RequireLicenseAcceptance flag to true.
Example 2: Install Module requiring license acceptanceInstall-Module -Name ModuleRequireLicenseAcceptance
License Acceptance
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"):
This command shows the license from license.txt
file and prompts the user to accept the license.
Install-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
Module is installed without any prompt to accept license.
Example 4: Install Module requiring license acceptance with -ForceInstall-Module -Name ModuleRequireLicenseAcceptance -Force
PackageManagement\Install-Package : License Acceptance is required for module 'ModuleRequireLicenseAcceptance'. Please specify '-AcceptLicense' to perform this operation.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.3\PSModule.psm1:1837 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
xception
+ FullyQualifiedErrorId : ForceAcceptLicense,Install-PackageUtility,Microsoft.PowerShell.PackageManagement.Cmdlets
.InstallPackage
Example 5: Install Module with dependencies requiring license acceptance
Module ModuleWithDependency depends on module ModuleRequireLicenseAcceptance. User is prompted to accept license.
Install-Module -Name ModuleWithDependency
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"):
Example 6: Install Module with dependencies requiring license acceptance and -AcceptLicense
Module ModuleWithDependency depends on module ModuleRequireLicenseAcceptance. User is not prompted to accept license as AcceptLicense is specified.
Install-Module -Name ModuleWithDependency -AcceptLicense
Example 7: Install module requiring license acceptance on a client older than PSGetFormatVersion 2.0
Install-Module -Name ModuleRequireLicenseAcceptance
WARNING: The specified module 'ModuleRequireLicenseAcceptance' with PowerShellGetFormatVersion
'2.0' is not supported by the current version of PowerShellGet. Get the latest version of the
PowerShellGet module to install this module, 'ModuleRequireLicenseAcceptance'.
Example 8: Save Module requiring license acceptance
Save-Module -Name ModuleRequireLicenseAcceptance -Path C:\Saved
License Acceptance
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"):
This command shows the license from license.txt
file and prompts the user to accept the license.
Save-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense -Path C:\Saved
Module is saved without any prompt to accept license.
Example 10: Update Module requiring license acceptanceUpdate-Module -Name ModuleRequireLicenseAcceptance
License Acceptance
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"):
This command shows the license from license.txt
file and prompts the user to accept the license.
Update-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
Module is updated without any prompt to accept license.
More detailsRequire License Acceptance for Scripts
Require License Acceptance support on PowerShellGallery
Require License Acceptance on Deploy to Azure Automation
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4