You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows Server 2016中BPA扫描执行失败,执行策略被覆盖求助

环境信息

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

问题现象

执行BPA扫描时,无论通过**服务器管理器(Server Manager)**还是PowerShell执行get-bpamodel命令,均返回以下错误:

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中执行get-bpamodel后,Process范围的执行策略会被修改为RemoteSigned(如下),关闭窗口重新打开提升权限的PowerShell后,执行策略恢复原有设置:

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

已排查/尝试的操作

  • 将服务器从影响PowerShell脚本执行的企业组策略(GPO)中移除,通过RSOP.msc确认相关策略已设为“未配置”并重启服务器
  • 手动将所有执行策略设置为Bypass,设置后的执行策略列表如下:
Scope ExecutionPolicy
        ----- ---------------
MachinePolicy    Unrestricted
   UserPolicy    Unrestricted
      Process          Bypass
  CurrentUser          Bypass
 LocalMachine          Bypass
  • 使用本地管理员而非域管理员执行操作,问题依旧
  • 将GPO策略设置为允许所有脚本运行(Unrestricted),问题未解决
  • 通过以下命令执行单独脚本,错误仍存在:
powershell.exe -executionpolicy bypass C:\Users\Public\bpagit.ps1

求助需求

目前不确定遗漏了哪些配置,恳请提供解决建议!

内容的提问来源于stack exchange,提问作者BraveITMan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 11:27:33