我试图运行一个[tag:cmd]文件,该文件从cmd.exe
调用一个[tag:powershell]脚本,但我得到了以下错误。
Management_Install.ps1
不能被加载,因为在这个系统上脚本的执行被禁止。
我已经运行了
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
当我从[tag:powershell]运行Get-ExecutionPolicy
时,我得到了Unrestricted
的回复。
PS C:\Users\Administrator\> Get-ExecutionPolicy
Unrestricted
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\> powershell .\Management_Install.ps1 1
WARNING: Running x86 PowerShell...
文件
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\Management_Install.ps1
不能被加载,因为在这个系统中脚本的执行被禁止。请参阅"get-help about_signing
"了解更多细节。
在行:1 char:25
.
Management_Install.ps1` <<<< 1
- CategoryInfo : 未指定。(:) [], PSSecurityException
- FullyQualifiedErrorId : RuntimeException
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\> PAUSE
Press any key to continue . . .
该系统是Windows Server 2008R2。
我做错了什么?
如果你使用的是Windows Server 2008R2,那么有一个_x64_和_x86_版本的PowerShell,它们都必须设置其执行策略。你在两台主机上都设置了执行策略吗?
作为一个管理员,你可以通过在PowerShell窗口中输入这个来设置执行策略。
Set-ExecutionPolicy RemoteSigned
更多信息,请参阅使用Set-ExecutionPolicy Cmdlet。