両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン最新のリビジョン両方とも次のリビジョン |
windows:powershell:commands:execution_policy [2020/02/23 01:30] – [Get-ExecutionPolicy/Set-ExecutionPolicy] ともやん | windows:powershell:commands:execution_policy [2020/02/23 02:00] – [参考文献] ともやん |
---|
**動作: Windows/Linux**\\ | **動作: Windows/Linux**\\ |
\\ | \\ |
| ===== Get-ExecutionPolicy ===== |
**Windows**\\ | **Windows**\\ |
<code powershell> | <code powershell> |
</code> | </code> |
| |
| ===== Set-ExecutionPolicy ===== |
**Windows**\\ | **Windows**\\ |
<code powershell> | <code powershell> |
Set-ExecutionPolicy: Operation is not supported on this platform. | Set-ExecutionPolicy: Operation is not supported on this platform. |
</code> | </code> |
| |
| ===== ExecutionPolicy ===== |
| 実行ポリシーを指定する。グループポリシーがなく、各スコープの実行ポリシーが **Undefined** に設定されている場合、**Restricted** がすべてのユーザーに有効なポリシーになる。\\ |
| ^ ポリシー ^ 説明 ^ |
| | AllSigned | ローカルコンピューターで記述されたスクリプトを含む、すべてのスクリプトと構成ファイルが信頼できる発行元によって署名されている必要がある。 | |
| | Bypass | 何もブロックされず、警告もプロンプトも表示されない。 | |
| | Default | デフォルトの実行ポリシーを設定する。Windows クライアントの場合は **Restricted**、Windows Server の場合は **RemoteSigned**。 | |
| | RemoteSigned | インターネットからダウンロードしたすべてのスクリプトと構成ファイルは、信頼できる発行元によって署名されている必要がある。Windows Server の既定の実行ポリシー。 | |
| | Restricted | 構成ファイルをロードしたり、スクリプトを実行したりしない。Windows クライアントの既定の実行ポリシー。 | |
| | Undefined | スコープに実行ポリシーは設定されていない。グループポリシーによって設定されていないスコープから、割り当てられた実行ポリシーを削除する。すべてのスコープの実行ポリシーが **Undefined** の場合、有効な実行ポリシーは **Restricted**。 | |
| | Unrestricted | PowerShell 6.0 以降、これは Windows 以外のコンピューターのデフォルトの実行ポリシーであり、変更できない。すべての構成ファイルをロードし、すべてのスクリプトを実行する。インターネットからダウンロードした未署名のスクリプトを実行すると、実行する前に許可を求められる。 | |
| |
| ===== Scope ===== |
| 実行ポリシーの影響を受けるスコープを指定する。デフォルトのスコープは **LocalMachine**。\\ |
| ^ スコープ ^ 説明 ^ |
| | MachinePolicy | コンピューターのすべてのユーザーに対してグループポリシーによって設定されます。 | |
| | UserPolicy | コンピューターの現在のユーザーのグループポリシーによって設定されます。 | |
| | Process | 現在のPowerShellセッションのみに影響します。 | |
| | CurrentUser | 現在のユーザーのみに影響します。 | |
| | LocalMachine | コンピューターのすべてのユーザーに影響するデフォルトのスコープ。 | |
| |
===== 参考文献 ===== | ===== 参考文献 ===== |
[[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-7|Get-ExecutionPolicy]]\\ | [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-7|Get-ExecutionPolicy]]\\ |
[[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7|Set-ExecutionPolicy]]\\ | [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7|Set-ExecutionPolicy]]\\ |
| [[https://qiita.com/kikuchi/items/59f219eae2a172880ba6|PowerShellのExecutionPolicyのスコープとかについて詳しく - Qiita]]\\ |
| |