Skip to content

Instantly share code, notes, and snippets.

@devlights
Last active March 12, 2018 05:05
Show Gist options
  • Select an option

  • Save devlights/e6a9ef10668374ab197d3c9f15d9c237 to your computer and use it in GitHub Desktop.

Select an option

Save devlights/e6a9ef10668374ab197d3c9f15d9c237 to your computer and use it in GitHub Desktop.
[PowerShell] 起動時に ExecutionPolicy を指定して起動

PowerShell で起動時に ExecutionPolicy を指定して起動する

$ powershell -ExecutionPolicy [Restricted|AllSigned|RemoteSigned|Unrestricted|Bypass]

この指定の場合、スコープはデフォルトで Process となる。-Scope Processと指定した場合と同じ。

基本マシン単位での既定の設定 (Restricted) は変更せずに、毎回設定するほうがいい。

個人でローカルでちょこっと実行するだけのスクリプトなら Bypassでも良い。

PowerShell 起動後に ExecutionPolicy を変更する

powershell起動後は以下のように設定しても同じ事になる。

$ powershell
$ Set-ExecutionPolicy Bypass -Scope Process

上記を実行すると、本当に変更するかの確認が表示される。

確認を表示せずに即変更するには、以下のように -Forceパラメータを付与する。

$ powershell
$ Set-ExecutionPolicy Bypass -Scope Process -Force

上記は確認画面なしで即変更される。

@devlights
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment