Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
SAMENVATTING
Juridische afdelingen voor sommige module-uitgevers vereisen dat klanten de licentie expliciet moeten accepteren voordat ze hun module installeren vanuit PowerShell Gallery. Als een gebruiker een module installeert, bijwerkt of opslaat met behulp van PowerShellGet, hetzij rechtstreeks, hetzij als afhankelijkheid voor een ander pakket, en voor die module moet de gebruiker akkoord gaan met een licentie, moet de gebruiker aangeven dat hij de licentie accepteert, anders mislukt de bewerking.
Vereisten voor modules publiceren
Modules waarvoor gebruikers verplicht moeten zijn om een licentie te accepteren, moeten aan de volgende vereisten voldoen:
- De PSData-sectie van het modulemanifest moet RequireLicenseAcceptance = $True bevatten.
- De module moet license.txt bestand in de hoofdmap bevatten.
- Het modulemanifest moet License Uri bevatten.
- De module moet worden gepubliceerd met PowerShellGet Format versie 2.0 en hoger.
Impact op Installeren/OpslaanUpdate-Module
- Cmdlets Install/Save/Update 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 gebruiker de license.txt, weergegeven en wordt de volgende melding gemaakt: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 scope)
- Update-Module: de module wordt geüpdatet.
 
- Als de licentie wordt geweigerd.
- De werking is geannuleerd.
- Alle cmdlets controleren op de metagegevens (requireLicenseAcceptance en Format Version) die aangeven dat een licentieacceptatie vereist is
- Als de formaatversie 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 een indelingsversie ouder dan 2.0, wordt de vlag requireLicenseAcceptance genegeerd.
 
 
- Als de licentie wordt geaccepteerd 
Module afhankelijkheden
- Als tijdens de bewerking Installeren/Opslaan/Bijwerken een licentie vereist (iets anders hangt af van de module) licentieacceptatie vereist, is het licentieacceptatiegedrag (hierboven) vereist.
- Als de moduleversie al in de lokale catalogus staat vermeld als geïnstalleerd op het systeem, zouden we de licentiecontrole omzeilen.
- Als tijdens de bewerking Installeren/Opslaan/Bijwerken een licentie vereist voor een afhankelijke module en de licentieacceptatie niet plaatsvindt, mislukt de bewerking en volgt deze de normale processen voor het pakket dat niet kan worden geïnstalleerd/opgeslagen/bijgewerkt.
Impact op -Force
Specificeren –Force is NIET voldoende om een licentie te accepteren. 
              –AcceptLicense is vereist voor toestemming om te installeren. Als –Force RequiredLicenseAcceptance is True en –AcceptLicense NOT is opgegeven, mislukt de bewerking.
VOORBEELDEN
Voorbeeld 1: Modulemanifest bijwerken om licentieacceptatie 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 vereist is
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: Installatiemodule waarvoor licentieacceptatie is vereist met -AcceptLicense
Install-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
De module wordt geïnstalleerd zonder dat u hoeft te worden gevraagd de licentie te accepteren.
Voorbeeld 4: Installatiemodule 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 licentieacceptatie 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 zijn vereist
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: 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 vereist is
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 licentieacceptatie is vereist met -AcceptLicense
Save-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense -Path C:\Saved
De module wordt opgeslagen zonder dat u hoeft te worden gevraagd de licentie te accepteren.
Voorbeeld 10: Updatemodule waarvoor licentieacceptatie vereist is
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: Updatemodule waarvoor licentieacceptatie is vereist met -AcceptLicense
Update-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
De module wordt bijgewerkt zonder dat u hoeft te worden gevraagd de licentie te accepteren.
Meer informatie
Licentieacceptatie voor scripts vereisen
Ondersteuning voor licentieacceptatie vereisen op PowerShellGallery
Licentieacceptatie vereisen bij implementatie naar Azure Automation
PowerShell Gallery