[英]Visual Studio Code Unsigned Powershell Scripts
我開始使用 Visual Studio Code 進行 Powershell 腳本編寫。 我想關閉對未簽名代碼的檢查,但不知道如何執行此操作。 我也沒有在論壇上找到任何東西。
您可以通過向 powershell.exe 命令添加參數來調整策略。 為此,打開設置 json 文件。 然后添加以下行:
"terminal.integrated.shellArgs.windows": "-ExecutionPolicy ByPass",
我通過將策略設置為:
Set-ExecutionPolicy –ExecutionPolicy RemoteSigned
到以管理員身份運行的 Visual code 集成環境。
下面的博客清楚地列出了解決它的步驟:
PowerShell 的默認設置有助於防止運行惡意腳本。 默認情況下,您應該/可以在 VSCode 集成終端上運行腳本。
要更改 PowerShell 安全設置,請使用管理員權限打開 PowerShell 並運行以下命令:
Get-ExecutionPolicy -List
你應該得到這樣的回應:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine AllSigned
CurrentUser 也可能未定義,因為您無法在 VSCode 終端上運行腳本。
要更改它,請運行以下命令:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
重新打開 VSCode 終端,它現在應該可以工作了。
如果您想了解更多詳細信息,可以在此處找到完整的文檔: https : //docs.microsoft.com/es-es/powershell/module/microsoft.powershell.core/about/about_execution_policies? view =powershell-7
我開始使用Visual Studio Code編寫Powershell腳本。 我想關閉未簽名代碼的檢查,但無法找到如何執行此操作。 我也沒有在論壇中找到任何東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.