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

常绿

当我执行.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”“-命令”“ if(((Get-ExecutionPolicy)-ne'AllSigned'){Set-ExecutionPolicy -Scope Process Bypass};&” C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe“ -Mta-文件'%1'”


我到这里来的问题视频

尝试这样做以观察一段时间后的行为:

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

由于脚本的执行可能受到限制,因此需要手动将其粘贴到PowerShell中。我目前的假设是,在重新启动/重新擦除内存后,执行策略将更改为,Undefined直到再次正确加载为止。防止弹出的方式就是-Force更改。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Powershell中显示消息框

如何从Powershell向Slack发布消息

如何绕过此Powershell警告消息?

如何在变量分配期间抑制PowerShell错误消息

如何在PowerShell中将此异常错误消息转换为我的自定义消息?

从 powershell 执行脚本时来自 python 的脚本进度消息

如何摆脱额外不相关的 PowerShell 消息

Azure Powershell函数如何向存储帐户队列添加消息

Powershell:如何从事件日志的消息字段中提取时间?

如何成功更改执行策略并启用PowerShell脚本执行

如何在Powershell和nano下保存git commit消息?(Ctrl + O无效)

如何在没有错误消息或异常的情况下调试PowerShell进程

如何在控制台上显示PowerShell错误消息并将其写入日志?

如果在确认消息框中按“否”,如何在Powershell中停止事件

如何在 TeamCity 构建项目中的 Powershell 脚本发送的 MS Teams 消息中放置超链接?

Powershell - MSExchange Set-Contact 如何在 cmdlet 返回错误消息时引发错误

禁用在 PowerShell 中调用命令后打印的横幅消息

PowerShell Azure 函数在没有错误消息的情况下执行时停止

如何平衡有关在Windows上安装Scoop的安全性(PowerShell执行策略更改)问题?

如何创建一个消息框作为 powershell.exe 的参数?

如何捕获输出消息并将其保存到powershell和SqlCmd中的变量

如何防止奇怪的Powershell黄绿色自动Web相关消息?

Powershell-如何显示消息并将用户输入保存到日志文件

Powershell邮件消息脚本

如何在sockjs上禁用调试消息-STOMP

如何在Fedora上禁用“无响应”消息

如何在Centos上禁用“上次登录失败”消息?

rhel +如何在我的机器上禁用CPU

Powershell使用发送邮件消息