[英]How to set the execution policy for the powershell_ise when it is launching?
[英]How can I bypass execution policy when running scripts from Powershell ISE
所以我可以在 Powershell ISE 中編寫一個腳本,而不是保存它,它會運行(ISE 上的 F5/綠色箭頭)。 保存后,我收到錯誤消息,提示我無法運行保存的腳本。 如果我在保存的腳本存在的目錄中打開一個 Powershell 窗口,我可以運行它
powershell -ExecutionPolicy ByPass -File script.ps1
但是,當我通過 ISE 的綠色箭頭/F5 運行它時,有沒有辦法讓它工作? 我沒有這台電腦的管理員權限
編輯:Windows 10
好的,我剛剛發現您可以為自己(當前用戶)設置執行策略而無需管理員權限。 所以如果你從谷歌來到這里,請執行以下操作:
Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
您還可以通過僅傳遞文件腳本的執行策略來運行單個腳本,而無需為當前用戶設置執行策略。
例如:
Powershell -executionpolicy RemoteSigned -File "C:\\scripts\\script.ps1"
非常方便在 Windows Task Scheduler 中的計划任務運行 PowerShell 命令(腳本)。
這是我對谷歌用戶的補充
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.