Skip to content

Instantly share code, notes, and snippets.

@stknohg
Last active March 6, 2020 09:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stknohg/328df73891b8e4f15327ba8a7ba90c47 to your computer and use it in GitHub Desktop.
Save stknohg/328df73891b8e4f15327ba8a7ba90c47 to your computer and use it in GitHub Desktop.
PowerShell実行ポリシーのメモ

実行ポリシー

設定値 内容
Restricted 個別のコマンドは許可されますが、スクリプトは実行されません。
AllSigned ローカル コンピューター上で記述されたスクリプトを含むすべてのスクリプトと構成ファイルが、信頼された発行元によって署名されている必要があります。
RemoteSigned インターネット (電子メールとインスタント メッセージング プログラムを含む) からダウンロードされたスクリプトと構成ファイルが、信頼された発行元によってデジタル署名されている必要があります。
Unrestricted 署名されていないスクリプトを実行できます。
Bypass 何もブロックされません。警告やプロンプトは表示されません。
Undefined 現在のスコープに実行ポリシーが設定されていません。すべてのスコープの実行ポリシーが Undefined の場合、有効な実行ポリシーは、既定の実行ポリシーである Restricted になります。

Windows PowerShell

OS 実行ポリシーの既定値
Windows 7 Restricted
Windows 8, 8.1 Restricted
Windows 10 Restricted
Windows Server 2008 R2 Restricted
Windows Server 2012 Restricted
Windows Server 2012 R2 RemoteSigned
Windows Server 2016 RemoteSigned

PowerShell Core

OS 実行ポリシーの既定値
Windows RemoteSigned
macOS Unrestricted
Linux Unrestricted

Get-ExecutionPolicy -Listの結果

Windows 8.1

PS C:\> Get-ExecutionPolicy -List | ft -AutoSize

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

Windows 10

PS C:\> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

Windows Server 2008 R2

PS C:\> Get-ExecutionPolicy -List | ft -AutoSize

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

Windows Server 2012

PS C:\> Get-ExecutionPolicy -List | ft -AutoSize

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

Windows Server 2012 R2

PS C:\> Get-ExecutionPolicy -List | ft -AutoSize

       Scope ExecutionPolicy
       ----- ---------------
MachinePolicy       Undefined
  UserPolicy       Undefined
     Process       Undefined
 CurrentUser       Undefined
LocalMachine    RemoteSigned

Windows Server 2016

PS C:\> Get-ExecutionPolicy -List

       Scope ExecutionPolicy
       ----- ---------------
MachinePolicy       Undefined
  UserPolicy       Undefined
     Process       Undefined
 CurrentUser       Undefined
LocalMachine    RemoteSigned

PowerShell Core on Windows

PS C:\> Get-ExecutionPolicy -List

       Scope ExecutionPolicy
       ----- ---------------
MachinePolicy       Undefined
  UserPolicy       Undefined
     Process       Undefined
 CurrentUser       Undefined
LocalMachine    RemoteSigned

PowerShell Core on macOS

PS /> Get-ExecutionPolicy -List                                                                               
       Scope ExecutionPolicy
       ----- ---------------
MachinePolicy    Unrestricted
  UserPolicy    Unrestricted
     Process    Unrestricted
 CurrentUser    Unrestricted
LocalMachine    Unrestricted

PowerShell Core on Linux

PS /> Get-ExecutionPolicy -List                                                                               
       Scope ExecutionPolicy
       ----- ---------------
MachinePolicy    Unrestricted
  UserPolicy    Unrestricted
     Process    Unrestricted
 CurrentUser    Unrestricted
LocalMachine    Unrestricted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment