[PowerShell]_解決錯誤”File cannot be loaded because the execution of scripts is disabled on this system”的問題

今天再用Azure,在寫PowerShell腳本排成開關機跟scale vm size時,是建立一個超小型的vm去handle這件事情

而OS是Windows 8.1 Enterprise,在執行PowerShell腳本之後,出現”File cannot be loaded because the execution of scripts is disabled on this system” 字樣

 

後來找了一下資料,找到

http://social.technet.microsoft.com/Forums/windowsserver/en-US/964636ad-347e-4b23-8f7a-f36a558115dd/error-file-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system?forum=winserverpowershell

此篇,裡面提到要用Set-ExecutionPolicy Unrestricted -Force這條指令下在PowerShell,但後來我又得到錯誤訊息,意思大概是這個policy還會有可能會被別的policy override

 

所以又找到http://stackoverflow.com/questions/16460163/ps1-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-syste

 

文說下達:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned

 

之後我的case就解決了…

 

目前是PowerShell新手…所以無法解釋太多,單純筆記一下。

Leave a comment 取消回覆

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

Exit mobile version