Modules die instemming met licentie vereisen

SAMENVATTING

Juridische afdelingen voor sommige module-uitgevers vereisen dat klanten de licentie expliciet accepteren voordat ze hun module installeren vanuit PowerShell Gallery. Als een gebruiker een module installeert, bijwerkt of opslaat met behulp van PowerShellGet, rechtstreeks of als een afhankelijkheid voor een ander pakket, en die module vereist dat de gebruiker akkoord gaat met een licentie, moet de gebruiker aangeven dat hij de licentie accepteert, anders mislukt de bewerking.

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.
  • Module moet license.txt-bestand in de hoofdmap bevatten.
  • Modulemanifest moet licentie-URI bevatten.
  • Module moet worden gepubliceerd met PowerShellGet Format versie 2.0 en hoger.

Gevolgen voor installeren/opslaan/bijwerken-module

  • Install/Save/Update-cmdlets ondersteunen een nieuwe parameter AcceptLicense die zich gedraagt alsof de gebruiker de licentie heeft gezien.
  • Als RequiredLicenseAcceptance True is en AcceptLicense niet is opgegeven, wordt de license.txtgebruiker weergegeven en wordt 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 het 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.

Moduleafhankelijkheden

  • Als tijdens de installatie/opslaan/bijwerken-bewerking voor een afhankelijke module (iets anders is afhankelijk van de module) licentie-acceptatie vereist is, is het gedrag voor het accepteren van licenties (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-bewerking voor een afhankelijke module een licentie is vereist en de licentieacceptatie niet plaatsvindt, mislukt de bewerking en volgt de normale processen voor het installeren/opslaan/bijwerken van het pakket is mislukt.

Impact op -Force

–Force Opgeven is NIET voldoende om een licentie te accepteren. –AcceptLicense is vereist voor de machtiging om te installeren. Als –Force is opgegeven, RequiredLicenseAcceptance waar is en –AcceptLicense NIET is 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 acceptatie van licenties 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 acceptatie van licenties 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: Installeer de module waarvoor licentieacceptatie 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 acceptatie van licenties is vereist

Module ModuleWithDependency is afhankelijk van module ModuleRequireLicenseAcceptance. De gebruiker wordt gevraagd 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 licentieacceptatie en -AcceptLicense vereist zijn

Module ModuleWithDependency is afhankelijk van module ModuleRequireLicenseAcceptance. De gebruiker wordt niet gevraagd om de licentie te accepteren omdat AcceptLicense is opgegeven.

Install-Module -Name ModuleWithDependency -AcceptLicense

Voorbeeld 7: Installeer de module 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: Sla de module op waarvoor licentieacceptatie is vereist met -AcceptLicense

Save-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense -Path C:\Saved

De module wordt opgeslagen zonder dat u wordt gevraagd om de licentie te accepteren.

Voorbeeld 10: Updatemodule vereist licentieacceptatie

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 acceptatie van licenties 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 acceptatie van licenties vereisen in PowerShellGallery

Acceptatie van de licentie vereisen bij implementeren naar Azure Automation