Aracılığıyla paylaş


Lisans Kabulü Gerektiren Modüller

ÖZET

Bazı modül yayımcılarının hukuk departmanları, müşterilerin modüllerini PowerShell Galerisi yüklemeden önce lisansı açıkça kabul etmelerini gerektirir. Bir kullanıcı PowerShellGet kullanarak doğrudan veya başka bir pakete bağımlılık olarak bir modülü yükler, güncelleştirir veya kaydederse ve bu modül kullanıcının bir lisansı kabul etmesini gerektiriyorsa, kullanıcının lisansı kabul ettiğini belirtmesi gerekir, aksi takdirde işlem başarısız olur.

Modüller için Yayımlama Gereksinimleri

Kullanıcıların lisansı kabul etmesini gerektiren modüller aşağıdaki gereksinimleri karşılamalıdır:

  • Modül bildiriminin PSData bölümü RequireLicenseAcceptance = $True içermelidir.
  • Modül, kök dizinde license.txt dosya içermelidir.
  • Modül bildirimi Lisans Uri'sini içermelidir.
  • Modül PowerShellGet Format Sürüm 2.0 ve üzeri ile yayımlanmalıdır.

Yükleme/Kaydetme/Update-Module Üzerindeki Etkisi

  • Install/Save/Update cmdlet'leri, kullanıcı lisansı görmüş gibi davranan yeni bir AcceptLicense parametresini destekler.
  • RequiredLicenseAcceptance True ise ve AcceptLicense belirtilmezse, kullanıcıya gösterilir license.txtve şu şekilde sorulur: Do you accept these license terms (Yes/No/YesToAll/NoToAll).
    • Lisans kabul edilirse
      • Save-Module: modül kullanıcının sistemine kopyalanır
      • Install-Module: modül kullanıcının sistemine uygun klasöre kopyalanır (kapsama göre)
      • Update-Module: modül güncellenir.
    • Lisans reddedilirse.
      • İşlem iptal edilir.
      • Tüm cmdlet'ler, lisans kabulünün gerekli olduğunu belirten meta verileri (requireLicenseAcceptance ve Format Version) denetler
      • İstemcinin biçim sürümü 2.0'dan eskiyse işlem başarısız olur ve kullanıcıdan istemciyi güncelleştirmesini ister.
      • Modül 2.0'dan eski biçim sürümüyle yayımlandıysa, requireLicenseAcceptance bayrağı yoksayılır.

Modül Bağımlılıkları

  • Install/Save/Update işlemi sırasında, bağımlı bir modül (modüle bağlı başka bir şey) lisans kabulü gerektiriyorsa, lisans kabul davranışı (yukarıda) gereklidir.
  • Modül sürümü yerel katalogda zaten sistemde yüklü olarak listeleniyorsa, lisans kontrolünü atlarız.
  • Install/Save/Update işlemi sırasında, bağımlı bir modül lisans gerektiriyorsa ve lisans kabulü gerçekleşmezse, işlem başarısız olur ve paketin yüklenemediği/kaydedilemediği/güncellenemediği için normal işlemleri izler.

-Force üzerindeki etkisi

Belirtmek –Force , bir lisansı kabul etmek için yeterli DEĞİLDİR. –AcceptLicense kurulum izni için gereklidir. Belirtilirse –Force , RequiredLicenseAcceptance True olur ve –AcceptLicense BELİRTİLMEZ, işlem başarısız olur.

ÖRNEKLER

Örnek 1: Lisans kabulü gerektirmek için Modül Bildirimi'ni güncelleştirme

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

Bu komut bildirim dosyasını güncelleştirir ve RequireLicenseAcceptance bayrağını true olarak ayarlar.

Örnek 2: Lisans kabulü gerektiren Modülü Yükleme

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"):

Bu komut, dosyadaki license.txt lisansı gösterir ve kullanıcıdan lisansı kabul etmesini ister.

Örnek 3: -AcceptLicense ile lisans kabulü gerektiren Modülü Yükleme

Install-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense

Modül, lisansı kabul etmek için herhangi bir istem olmadan kurulur.

Örnek 4: -Force ile lisans kabulü gerektiren Modülü Yükleme

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

Örnek 5: Lisans kabulü gerektiren bağımlılıklara sahip Modülü Yükleme

ModuleWithDependency modülü, ModuleRequireLicenseAcceptance modülüne bağlıdır. Kullanıcıdan lisansı kabul etmesi istenir.

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"):

Örnek 6: Lisans kabulü ve -AcceptLicense gerektiren bağımlılıklarla Modülü Yükleme

ModuleWithDependency modülü, ModuleRequireLicenseAcceptance modülüne bağlıdır. AcceptLicense belirtildiğinden kullanıcıdan lisansı kabul etmesi istenmez.

Install-Module -Name ModuleWithDependency -AcceptLicense

Örnek 7: PSGetFormatVersion 2.0'dan eski bir istemcide lisans kabulü gerektiren yükleme modülü

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'.

Örnek 8: Lisans kabulü gerektiren Modülü Kaydet

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"):

Bu komut, dosyadaki license.txt lisansı gösterir ve kullanıcıdan lisansı kabul etmesini ister.

Örnek 9: -AcceptLicense ile lisans kabulü gerektiren Modülü Kaydet

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

Modül, lisansı kabul etmek için herhangi bir istem olmadan kaydedilir.

Örnek 10: Lisans kabulü gerektiren Güncelleme Modülü

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"):

Bu komut, dosyadaki license.txt lisansı gösterir ve kullanıcıdan lisansı kabul etmesini ister.

Örnek 11: Lisans kabulü gerektiren Modülü -AcceptLicense ile güncelleyin

Update-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense

Modül, lisansı kabul etmek için herhangi bir istem olmadan güncellenir.

Diğer ayrıntılar

Komut dosyaları için lisans kabulü gerektir

PowerShellGallery'de Lisans Kabulü desteği gerektir

Azure otomasyonuna dağıtma sırasında lisans kabulü gerektirme