繁体   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