UJP - 技術情報2 : PowerShellの実行ポリシー PowerShell/01/Get-ExecutionPolicy

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

Page Top

はじめに anchor.png Edit

 PowerShellを使ってみようとして,いきなり動かない.PowerShellは強力な機能が故に,セキュリティホールになるから,デフォルトでは実行できないように設定してある.  このドキュメントでは,実行ポリシー(Execution Policy)を確認して,変更する手順を示す.

Page Top

実行ポリシーの現在設定を確認 anchor.png Edit

 コマンドプロンプトから,PowerShellを実行して,Get-ExecutionPolicyコマンドレットを実行させて,現在設定を確認する.

index.php?page=view&file=6558&PowerShellExecutionPolicy1.jpg

 restrictedとレスポンスがあったので,制限された状態.

 PowerShellの開発環境,PowerShell ISEを使ってコマンドレットを実行.

index.php?page=view&file=6559&PowerShellExecutionPolicy2.jpg

 すると,エラーが.

このシステムではスクリプトの実行が無効になっているため、
ファイル C:\Users\ujpadmin\Desktop\getPolicy.ps1 を
読み込むことができません。
詳細については、「about_Execution_Policies」
(https://go.microsoft.com/fwlink/?LinkID=135170) を参照してください。」

 実行ポリシーの変更が必要.

Page Top

実行ポリシーをUnrestrictedにする anchor.png Edit

 実行ポリシーには,restricted,AllSigned,RemoteSigned,Unrestrictedと制限が強い順に設定できるが,ここでは一番弱いUnrestrictedに変更する.

index.php?page=view&file=6560&PowerShellExecutionPolicy3.jpg

 管理者権限がなかったのでエラーになった.

index.php?page=view&file=6554&PowerShellExecutionPolicy4.jpg

 スタートメニューを右クリックして,PowerShellを管理者モードで開く.

index.php?page=view&file=6556&PowerShellExecutionPolicy5.jpg

 Set-ExecutionPolicyにて,unrestrictedを設定できた.


Front page   Edit Diff Backup Upload Copy Rename Reload   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)
Counter: 1315, today: 1, yesterday: 0
Last-modified: 2019-12-19 (Thu) 00:45:22 (JST) (1864d) by nobuaki

広告スペース
Google