0
我創建了PowerShell腳本來從子文件夾獲取文件。這時候執行我後手動輸入Set-ExecutionPolicy unrestricted
從PowerShell控制檯運行,但是當我打電話相同的腳本從批處理文件在從批處理文件調用powershell腳本時執行策略錯誤,powershell v 1.0
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe D:\programs\abc\bin\xyz_clean.ps1
它拋出一個錯誤:
xyz_clean.ps1 cannot be loaded because the execution of scripts is disabled on this system.
你在運行什麼操作系統(包括32位和64位)? – alroc 2013-03-05 15:20:45
您是否試過在批處理中指定執行策略? 'C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ PowerShell.exe -executionpolicy unrestricted -file D:\ programs \ abc \ bin \ xyz_clean.ps1' 除此之外,您的「每位用戶「和」機器「執行策略,你可以嘗試使用你缺少-file選項的set-executionpolicy – Poorkenny 2013-03-05 15:22:57
的'-scope'參數。 PowerShell腳本是否被組策略拒絕? – 2013-03-05 15:23:58