概要
一部のモジュール発行元の法務部門では、PowerShell ギャラリーからモジュールをインストールする前に、顧客がライセンスに明示的に同意する必要があります。 ユーザーが PowerShellGet を使用してモジュールを直接または別のパッケージの依存関係としてインストール、更新、または保存し、そのモジュールでユーザーがライセンスに同意する必要がある場合、ユーザーはライセンスに同意することを示す必要があり、そうでない場合は操作が失敗します。
モジュールの公開要件
ユーザーにライセンスの同意を要求するモジュールは、次の要件を満たす必要があります。
- モジュール マニフェストの PSData セクションには、RequireLicenseAcceptance = $True を含める必要があります。
- モジュールには license.txt ルートディレクトリにファイルが含まれている必要があります。
- モジュール マニフェストにはライセンス URI が含まれている必要があります。
- モジュールは、PowerShellGet 形式バージョン 2.0 以降で発行する必要があります。
インストール/保存/Update-Module への影響
- インストール/保存/更新コマンドレットでは、ユーザーがライセンスを見たかのように動作する新しいパラメーター AcceptLicense がサポートされています。
-
RequiredLicenseAcceptance が True で、AcceptLicense が指定されていない場合、ユーザーに
license.txtが表示され、Do you accept these license terms (Yes/No/YesToAll/NoToAll)というプロンプトが表示されます。- ライセンスが承認された場合
- Save-Module: モジュールがユーザーのシステムにコピーされます
- Install-Module: モジュールはユーザーのシステムに適切なフォルダーにコピーされます (スコープに基づく)
- Update-Module: モジュールが更新されます。
- ライセンスが拒否された場合。
- 操作がキャンセルされます。
- すべてのコマンドレットは、ライセンスへの同意が必要であることを示すメタデータ (requireLicenseAcceptance と Format Version) をチェックします
- クライアントのフォーマットバージョンが2.0より古い場合、操作は失敗し、ユーザーにクライアントの更新を求めます。
- モジュールが 2.0 より古いフォーマット バージョンで公開された場合、requireLicenseAcceptance フラグは無視されます。
- ライセンスが承認された場合
モジュールの依存関係
- インストール/保存/更新操作中に、依存モジュール (モジュールに依存する他のもの) がライセンスの同意を必要とする場合は、ライセンスの同意動作 (上記) が必要です。
- モジュールのバージョンがシステムにインストールされているものとしてローカルカタログにすでにリストされている場合は、ライセンスチェックをバイパスします。
- インストール/保存/更新操作中に、依存モジュールにライセンスが必要であり、ライセンスの受け入れが行われない場合、操作は失敗し、パッケージのインストール/保存/更新に失敗した通常のプロセスに従います。
-Force への影響
–Forceを指定するだけでは、ライセンスを受け入れるには十分ではありません。
–AcceptLicense インストールの許可に必要です。
–Forceが指定され、RequiredLicenseAcceptance が True で、–AcceptLicense が指定されていない場合、操作は失敗します。
例の数々
例 1: ライセンスへの同意を要求するようにモジュール マニフェストを更新する
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
このコマンドは、マニフェスト ファイルを更新し、RequireLicenseAcceptance フラグを true に設定します。
例 2: ライセンスへの同意が必要なモジュールのインストール
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"):
このコマンドは、 license.txt ファイルからライセンスを表示し、ユーザーにライセンスに同意するように求めます。
例 3: -AcceptLicense でのライセンスへの同意を必要とするモジュールのインストール
Install-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
モジュールは、ライセンスを受け入れるプロンプトなしでインストールされます。
例 4: -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
例 5: ライセンスの同意を必要とする依存関係を持つモジュールをインストールする
モジュール ModuleWithDependency は、モジュール ModuleRequireLicenseAcceptance に依存します。 ユーザーにライセンスを受け入れるように求められます。
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"):
例 6: ライセンスの同意と -AcceptLicense を必要とする依存関係を持つモジュールをインストールする
モジュール ModuleWithDependency は、モジュール ModuleRequireLicenseAcceptance に依存します。 AcceptLicense が指定されているため、ユーザーにライセンスの同意を求められることはありません。
Install-Module -Name ModuleWithDependency -AcceptLicense
例 7: 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'.
例 8: ライセンスの同意を必要とするモジュールの保存
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"):
このコマンドは、 license.txt ファイルからライセンスを表示し、ユーザーにライセンスに同意するように求めます。
例 9: -AcceptLicense でライセンスの同意を必要とするモジュールの保存
Save-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense -Path C:\Saved
モジュールは、ライセンスを受け入れるプロンプトなしで保存されます。
例 10: ライセンスへの同意を必要とするモジュールの更新
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"):
このコマンドは、 license.txt ファイルからライセンスを表示し、ユーザーにライセンスに同意するように求めます。
例 11: -AcceptLicense でライセンスの受け入れを必要とする更新モジュール
Update-Module -Name ModuleRequireLicenseAcceptance -AcceptLicense
モジュールは、ライセンスを受け入れるプロンプトなしで更新されます。
詳細
PowerShell Gallery