如何修复 "WinRM服务无法处理请求,因为DeliverTo中的wsman:ConnectionRetry元素是无效的.
描述
This error occurs in Microsoft Windows environments when using Windows Remote Management (WinRM) for event forwarding, remote scripting, or WS-Management sessions. It specifically indicates a schema validation failure within the SOAP request payload sent to the WinRM service.
没有 DeliverTo element in the WS-Eventing or WS-Management XML structure defines how and where notifications or responses should be delivered. Inside this structure, the wsman:ConnectionRetry element tells the service how many times or how frequently it should attempt to reconnect if a connection fails.
由于两个主要原因,WinRM服务会出现此错误:
- Invalid Value Data Types: 提供的值在
<wsman:ConnectionRetry>标签不符合预期的 XML 数据类型 (如整数或特定持续时间格式). - Schema Mismatch (WS-Management Version Compatibility): 生成请求的客户端应用程序使用过时或非标准的WS管理协议实现,引入接收Windows WinRM服务无法解析或明确拒绝的语法元素.
逐步修复问题
根据您是否正在运行事件订阅,执行自定义 PowerShell 脚本或管理第三方监控工具,请使用以下方法来解决问题.
方法1:在事件订阅中修改或删除connectionRetry参数
如果您正在使用 Windows 事件转发 (WEF),则重试元素通常在订阅配置内定义.
- 打开 PowerShell 作为一个管理员.
- 将您的当前订阅配置导出到 XML 文件,运行:
wecutil gs "YourSubscriptionName" /f:xml > C:\subscription.xml - 打开
C:\subscription.xml使用 Notepad 或一个 XML 编辑器. - 搜索一个
<wsman:ConnectionRetry>标签. - Verify its value. If it contains invalid characters, symbols, or letters, change it to a valid integer (for example,
5) 没有. - 如果您的工作流程不严格要求该参数,请删除整个参数.
<wsman:ConnectionRetry>...</wsman:ConnectionRetry>封锁文件. - 保存并关闭文件.
- 使用修改后的 XML 文件更新 Windows 中的订阅:
wecutil ss /c:C:\subscription.xml
方法2:更新第三方监控代理或管理软件
如果 Linux 服务器,监控工具 (如 Nagios,Zabbix,SolarWinds) 或备份系统连接到您的 Windows 机器时出现此错误,则客户端软件正在发送错误的 XML 头.
- 识别启动 Windows 机器远程连接的软件.
- 检查供应商的文件是否已知. WinRM compatibility patches.
- 将客户端上的管理代理,SDK或命令行实用程序更新到最新版本.
- 如果您正在使用自定义的Python脚本 (例如,通过
pywinrm确保您的库更新, 因为旧版本有某些WS-Man扩展程序的格式错误.
方法3:重新启动和重置 WinRM 服务配置
损坏的 WinRM 收听器或冲突的配置策略可能导致解析错误.重置服务可确保应用标准参数.
- 按下 Windows Key + X 并且选择 Terminal (Admin) 或是 Command Prompt (Admin).
- 通过输入停止 WinRM 服务:
net stop winrm - 将 WinRM 默认配置参数重置到工厂设置:
winrm quickconfig -q - 检查听众的健康状况,
winrm e winrm/config/listener - 重新启动 WinRM 服务:
net start winrm
方法4:调整WSman重试注册表值 (用于高级环境)
如果群组策略或注册表配置正在推动严格或腐败的WS-Management交付设置,您可以检查注册表.
- 按下 Windows Key + R, 类型
regedit,并击中 Enter 打开注册表编辑器. - 导航到以下路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\ - 寻找任何与
Client或是Service定义自定义重试配置. - 确保没有字符串值 (
REG_SZ) 在重试数量预期的 DWORD 值时被分配. - 关闭注册表编辑器并重新启动计算机,以应用更改.
可能有一些错误.. Learn Microsoft