Modules die instemming met licentie vereisen
SAMENVATTING
Juridische afdelingen voor sommige moduleuitgevers vereisen dat klanten de licentie expliciet accepteren voordat ze hun module van PowerShell Gallery installeren. Als een gebruiker een module installeert, bijwerkt of opslaat met Behulp van PowerShellGet, hetzij rechtstreeks of als afhankelijkheid voor een ander pakket, en die module vereist dat de gebruiker akkoord gaat met een licentie, moet de gebruiker aangeven dat deze de licentie accepteert of dat de bewerking mislukt.
Vereisten voor publiceren voor modules
Modules die willen vereisen dat gebruikers een licentie accepteren, moeten voldoen aan de volgende vereisten:
- De sectie PSData van het modulemanifest moet RequireLicenseAcceptance = $True bevatten.
- De module moet license.txt bestand in de hoofdmap bevatten.
- Modulemanifest moet licentie-URI bevatten.
- De module moet worden gepubliceerd met PowerShellGet-indeling versie 2.0 en hoger.
Impact op installeren/opslaan/bijwerken-module
- Cmdlets installeren/opslaan/bijwerken ondersteunen een nieuwe parameter AcceptLicense die zich gedraagt alsof de gebruiker de licentie heeft gezien.
- Als RequiredLicenseAcceptance Waar is en AcceptLicense niet is opgegeven, wordt de gebruiker weergegeven
license.txten wordt hierom gevraagd:Do you accept these license terms (Yes/No/YesToAll/NoToAll).- Als de licentie wordt geaccepteerd
- Save-Module: de module wordt gekopieerd naar het systeem van de gebruiker
- Install-Module: de module wordt gekopieerd naar het systeem van de gebruiker naar de juiste map (op basis van bereik)
- Update-Module: de module wordt bijgewerkt.
- Als de licentie wordt geweigerd.
- De bewerking is geannuleerd.
- Alle cmdlets controleren op de metagegevens (requireLicenseAcceptance en Format Version) die aangeeft dat een licentieacceptatie is vereist
- Als de indelingsversie van de client ouder is dan 2.0, mislukt de bewerking en wordt de gebruiker gevraagd de client bij te werken.
- Als de module is gepubliceerd met de indelingsversie ouder dan 2.0, wordt de vlag requireLicenseAcceptance genegeerd.
- Als de licentie wordt geaccepteerd
Moduleafhankelijkheden
- Als tijdens de installatie-/opslaan/bijwerken-bewerking een afhankelijke module (iets afhankelijk van de module) vereist is dat de licentie wordt geaccepteerd, is het gedrag van de licentieacceptatie (hierboven) vereist.
- Als de moduleversie al in de lokale catalogus wordt vermeld als geïnstalleerd op het systeem, wordt de licentiecontrole overgeslagen.
- Als tijdens de installatie/opslaan/bijwerken van een afhankelijke module een licentie is vereist en de acceptatie van de licentie niet plaatsvindt, mislukt de bewerking en volgt u de normale processen voor het installeren/opslaan/bijwerken van het pakket niet.
Impact op -Force
–Force Opgeven is NIET voldoende om een licentie te accepteren. –AcceptLicense is vereist voor de machtiging om te installeren. Als –Force dit is opgegeven, is RequiredLicenseAcceptance True en –AcceptLicense is NIET opgegeven, mislukt de bewerking.
VOORBEELDEN
Voorbeeld 1: Modulemanifest bijwerken om acceptatie van licenties te vereisen
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
Met deze opdracht wordt het manifestbestand bijgewerkt en wordt de vlag RequireLicenseAcceptance ingesteld op true.
Voorbeeld 2: Module installeren waarvoor licentieacceptatie is vereist
Install-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"):
Met deze opdracht wordt de licentie uit license.txt het bestand weergegeven en wordt de gebruiker gevraagd de licentie te accepteren.
Voorbeeld 3: Module installeren waarvoor licentieacceptatie is vereist met -AcceptLicense
Install-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
De module wordt geïnstalleerd zonder dat u wordt gevraagd om de licentie te accepteren.
Voorbeeld 4: Module installeren waarvoor acceptatie van licenties is vereist met -Force
Install-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
Voorbeeld 5: Module installeren met afhankelijkheden waarvoor licentieacceptatie is vereist
Module ModuleWithDependency is afhankelijk van module ModuleRequireLicenseAcceptance. De gebruiker wordt gevraagd om de licentie te accepteren.
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"):
Voorbeeld 6: Module installeren met afhankelijkheden waarvoor acceptatie van licenties en -AcceptLicense is vereist
Module ModuleWithDependency is afhankelijk van module ModuleRequireLicenseAcceptance. De gebruiker wordt niet gevraagd om een licentie te accepteren omdat AcceptLicense is opgegeven.
Install-Module -Name ModuleWithDependency -AcceptLicense
Voorbeeld 7: Installatiemodule waarvoor licentieacceptatie is vereist op een client die ouder is dan 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'.
Voorbeeld 8: Module opslaan waarvoor licentieacceptatie is vereist
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"):
Met deze opdracht wordt de licentie uit license.txt het bestand weergegeven en wordt de gebruiker gevraagd de licentie te accepteren.
Voorbeeld 9: Module opslaan waarvoor acceptatie van licenties is vereist met -AcceptLicense
Save-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense -Path C:\Saved
De module wordt opgeslagen zonder prompt om de licentie te accepteren.
Voorbeeld 10: Module bijwerken waarvoor licentieacceptatie is vereist
Update-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"):
Met deze opdracht wordt de licentie uit license.txt het bestand weergegeven en wordt de gebruiker gevraagd de licentie te accepteren.
Voorbeeld 11: Module bijwerken waarvoor licentieacceptatie is vereist met -AcceptLicense
Update-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
De module wordt bijgewerkt zonder dat u wordt gevraagd om de licentie te accepteren.
Meer informatie
Acceptatie van de licentie vereisen voor scripts
Ondersteuning voor licentieacceptatie vereisen in PowerShellGallery
Acceptatie van de licentie vereisen bij implementeren naar Azure Automation