2010-11-10 56 views
1

我试图使用外部程序,它将调用Powershell的问题运行外部程序

powershell.exe "& 'C:\Temp\myscript.ps1'" 

我已经设置为运行Windows Server 2008上简单的PowerShell脚本(如刚刚与dir命令)的.ps1脚本时(以管理员身份运行)execution-policy unrestricted。毕竟,我从客户端得到这个错误

99: File C:\Temp\myscript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please 
see "get-help about_signing" for more detai ls. At line:1 char:2 + & <<<< 'C:\Temp\myscript.ps1'  + CategoryInfo 
: NotSpecified: (:) [], PSSecurityException  + FullyQualifiedErrorId : RuntimeException 

为什么我得到这个错误?不是无限制的执行策略吗?

+2

问题解决:Windows Server 2008中有两个Powershell,x64和x86。我必须在其中设置执行策略不受限制。 – jjoras 2010-11-10 19:54:59

回答

4

或者

可以使用-ExecutionPolicy PowerShell.exe的参数设置执行策略,以不受限制只对会议。这有助于将整个系统的政策保持在不受约束的状态。