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

Add-MpPreference在部分Windows机器失效,如何使其正常运行?

解决Add-MpPreference/Remove-MpPreference执行失败的问题

针对Windows 11:"Add-MpPreference 未被识别"错误

排查与解决步骤

  • 确认Windows Defender是否激活
    若机器安装了第三方杀毒软件,Windows Defender会被自动禁用,这类cmdlet也会随之消失。可执行Get-MpComputerStatus验证,若返回错误则说明Defender未启用。
  • 手动导入Defender模块
    尝试手动加载模块:
    Import-Module Defender
    
    如果模块不存在,说明系统可能是精简版本,需通过控制面板启用Windows Defender防病毒功能。
  • 以管理员身份运行PowerShell
    这些cmdlet必须拥有管理员权限才能执行,右键PowerShell选择「以管理员身份运行」后再执行脚本。

针对Windows 10 LSTC:0x800106ba错误

排查与解决步骤

  • 检查Defender相关服务状态
    错误0x800106ba本质是RPC服务异常,需确保核心服务正常运行:
    # 启动WinDefend服务
    Get-Service WinDefend | Start-Service -ErrorAction SilentlyContinue
    # 启动WMI服务
    Get-Service Winmgmt | Start-Service -ErrorAction SilentlyContinue
    
  • 修复WMI存储库
    WMI损坏会导致CIM操作失败,执行以下命令修复:
    winmgmt /verifyrepository
    # 若验证不通过,执行 salvage 修复
    winmgmt /salvagerepository
    
  • 提升权限并规避拦截
    必须以管理员身份运行脚本,同时可临时关闭Defender实时防护测试(测试后及时开启),排除防护拦截的可能。

通用脚本优化建议

  • 先验证cmdlet存在性再执行
    在脚本中加入判断逻辑,避免无意义报错:
    if (Get-Command Add-MpPreference -ErrorAction SilentlyContinue) {
        Add-MpPreference -ExclusionPath "$SMTTempPath\SMTSetup.exe"
    } else {
        Write-Warning "Windows Defender cmdlet不可用,无法添加排除项"
    }
    
  • 确保路径格式正确
    用绝对路径执行操作,避免相对路径导致的识别问题:
    $exclusionPath = Resolve-Path "$SMTTempPath\SMTSetup.exe" -ErrorAction Stop
    Add-MpPreference -ExclusionPath $exclusionPath.Path
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 23:14:53