cmd
から PowerShell スクリプトを呼び出すファイルを実行しようとしていますcmd.exe
が、次のエラーが発生します:
Management_Install.ps1
このシステムではスクリプトの実行が無効になっているため、読み込むことができません。
次のコマンドを実行しました:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Get-ExecutionPolicy
PowerShell から実行すると、 が返されますUnrestricted
。
Get-ExecutionPolicy
出力:
Unrestricted
cd "C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts" powershell .\Management_Install.ps1 1
警告: x86 PowerShell を実行しています...
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\Management_Install.ps1
このシステムではスクリプトの実行が無効になっているため、ファイルを読み込むことができません。get-help about_signing
詳細については、「」を参照してください。行:1 文字:25
.\Management_Install.ps1
<<<< 1
カテゴリ情報: 未指定: (:) []、PSSecurityException
完全修飾エラー ID: ランタイム例外
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts> 一時停止
何かキーを押すと続行します 。 。 。
このシステムはWindows Server 2008R2.
何が間違っているのでしょうか?
ベストアンサー1
使用している場合Windows Server 2008R2 の場合、PowerShell のx64バージョンとx86バージョンがあり、両方の実行ポリシーを設定する必要があります。両方のホストで実行ポリシーを設定しましたか?
管理者は、PowerShell ウィンドウに次のように入力して実行ポリシーを設定できます。
Set-ExecutionPolicy RemoteSigned
詳細については、Set-ExecutionPolicy コマンドレットの使用。
完了したら、次のコマンドでポリシーをデフォルト値に戻すことができます。
Set-ExecutionPolicy Restricted
次のエラーが表示される場合があります:
Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
To change the execution policy for the default (LocalMachine) scope,
start Windows PowerShell with the "Run as administrator" option.
To change the execution policy for the current user,
run "Set-ExecutionPolicy -Scope CurrentUser".
したがって、次のようにコマンドを実行する必要があるかもしれません (コメントに記載されているとおり)。
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser