首页 > 解决方案 > 每次运行 powershell 脚本时都会出现 Set-ExecutionPolicy 错误

问题描述

每当我运行 powershell 脚本时,我都会收到错误消息:

Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting 
is overridden by
a policy defined at a more specific scope.  Due to the override, your shell will retain its current effective
execution policy of Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
information please see "Get-Help Set-ExecutionPolicy".

当我在 Powershell ISE 中运行脚本或在命令行上运行命令时,不会发生这种情况。有没有办法阻止这种情况发生?

标签: powershell

解决方案


如错误消息中所述,您可以检查Get-ExecutionPolicy -List所有策略。更详细的范围级别会覆盖更一般的级别。

就我而言,我通过在进程级别设置执行策略来解决它。

Set-Executionpolicy -ExecutionPolicy RemoteSigned -Scope Process

推荐阅读