2010-11-10 54 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的參數設置執行策略,以不受限制只對會議。這有助於將整個系統的政策保持在不受約束的狀態。