簡體   English   中英

如何在較慢或非常繁忙的 CPU 機器上禁用“執行策略更改”powershell 消息?

[英]How to disable “execution Policy Change” powershell message on Slower or very busy CPU machine?

我最近在執行 .ps1 腳本文件時收到了 powershell 消息“執行策略已更改”消息

--------------
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):
---------------

這是不可接受的,因為我在 CurrectUser 上設置了不受限制。

    ----
    Scope ExecutionPolicy
    ----- ---------------
    MachinePolicy       Undefined
    UserPolicy       Undefined
    Process       Undefined
    CurrentUser    Unrestricted  <<< HERE
    LocalMachine       Undefined
    ----

有誰知道會發生什么???

這僅在機器 CPU 負載非常高(超過 80%)和/或 powershell 未緩存在 RAM 上時發生。

在此先感謝各位!!!

PS:這是雙擊行為的mi regedit條目:

HKEY_CLASSES_ROOT\\Microsoft.PowerShellScript.1\\Shell\\0\\Command =

"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" "-Command" "if((Get-ExecutionPolicy) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & "C: \\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -Mta -File '%1'"


我在這里遇到的問題的視頻

試試這個來觀察隨着時間的推移行為:

while ($true){ 
    powershell.exe -Command {Get-ExecutionPolicy }
    sleep 5
}

由於腳本的執行可能會受到限制,您需要手動將其粘貼到 PowerShell 中。 我目前的假設是,在重新啟動/內存擦除時,執行策略更改為Undefined直到再次正確加載。 防止彈出的方法是- -Force更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM