BPA - 尽管具有“不受限制”的流程执行,但最佳实践分析器仍无法运行

问题描述 投票:0回答:1

操作系统:Windows Server 2016 -- 版本 1607(操作系统内部版本 14393.6452) PowerShell:5.1.14393.6343

尝试运行 BPA 扫描时,它返回错误...

get-bpamodel : There has been an error while trying to set the process wide execution policy. (Inner Exception:
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".)
At line:1 char:1
+ get-bpamodel
+ ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-BpaModel], CommandLetException
    + FullyQualifiedErrorId : SetExecutionPolicyError,Microsoft.BestPractices.Cmdlets.GetModelCommand

从服务器管理器和 powershell 运行 BPA 扫描时会发生这种情况。

在测试服务器上工作时,我已从影响 PowerShell 脚本执行的企业 GPO 策略中删除了该计算机,并使用 RSOP.msc 进行了确认 - 重新启动并确认该策略已设置为“未配置”。为了测试目的,我已手动将所有内容设置为“绕过”。

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy    Unrestricted
   UserPolicy    Unrestricted
      Process          Bypass
  CurrentUser          Bypass
 LocalMachine          Bypass

从提升的 powershell 窗口或服务器管理器(提升的和非提升的)运行“get-bpadmodel”会返回上述错误消息,但是当从 powershell 运行时,它也会将“Process”的执行策略更改为“RemoteSigned”(以下)。如果我关闭该窗口并重新启动提升的 powershell,它将恢复到上面的 ExecutionPolicy。 Scope ExecutionPolicy ----- --------------- MachinePolicy Unrestricted UserPolicy Unrestricted Process RemoteSigned CurrentUser Bypass LocalMachine Bypass

我尝试以本地管理员而不是网络管理员的身份运行:同样的错误。设置 GPO 策略以允许所有脚本运行,即“不受限制”:相同的错误。我尝试通过单独的脚本(如下)传输命令:同样的错误。

powershell.exe -executionpolicy bypass C:\Users\Public\bpagit.ps1

我不确定我错过了什么,但任何建议都会有帮助!

powershell windows-server-2016 gpo servermanager executionpolicy
1个回答
0
投票

我为测试机设置了“AllSigned”企业 GPO 策略,并且能够通过 GUI 运行扫描,这足以满足我的需求。

请注意,这不适用于“无限制”或未配置的企业 GPO 策略。

© www.soinside.com 2019 - 2024. All rights reserved.