当使用补丁管理器 AWS-RunPatchBaseline 文档时,如何排查与 Amazon EC2 Windows 实例相关的修补问题?
我想排查我在使用 AWS-RunPatchBasline 文档修补 Amazon Elastic Compute Cloud (Amazon EC2) Windows 节点时收到的错误。
简述
以下问题会导致您在使用适用于补丁管理器(AWS Systems Manager 的一项功能)的 AWS-RunPatchBaseline Systems Manager 命令文档 (SSM 文档)时出错:
- 您的 Amazon EC2 实例或托管节点无法访问 Amazon Simple Storage Service (Amazon S3) 端点。
- 令牌请求无效。
- 您的 EC2 实例无法搜索 Windows 更新。
- 下载更新后无法安装。
- 缺少补丁。
解决方法
排查无法访问 Amazon S3 端点的节点
以下错误消息表明实例无法连接到 Amazon S3 端点。之所以出现这些错误,也是因为附加到您实例的 AWS Identity and Access Management (IAM) 实例配置文件缺少连接端点所需的权限:
- "Invoke-PatchBaselineOperation : The underlying connection was closed: An unexpected error occurred on a send"
- "An error occurred when executing PatchBaselineOperations: Unable to connect to the remote server"
- "Invoke-PatchBaselineOperation : Access Denied"
要解决这些错误,请完成以下步骤:
- 检查实例配置文件的 IAM 权限是否附加到节点。有关最低权限,请参阅 AWS Systems Manager Agent (SSM Agent) 与 AWS 托管 S3 存储桶进行通信。
- 检查实例配置文件是否具有访问快速设置 S3 存储桶的权限。
- 如果配置文件缺少访问快速设置 S3 存储桶的权限,请将策略添加到您的配置文件。
- 要检查与端点的连接,请在 PowerShell 中运行以下命令:
注意: 将 example-region-id 替换为您的 AWS 区域 ID。tnc s3.example-region-id.amazonaws.com -port 443
如果您无法连接到端点,请执行以下操作之一:
排查无效的令牌请求
以下错误消息示例表明 SSM Agent 使用了不正确的凭证:
- "Invoke-PatchBaselineOperation failed with: The security token included in the request is invalid:"
- "Invoke-PatchBaselineOperation: Instance Id i-00fe5918abcdef12 doesn't match the credentials"
要解决这些错误,请更新 SSM Agent 到版本 3.2.183.0 或更高版本。
要使用较早的 SSM Agent 版本,请找到共享凭证,将其删除,然后再次测试补丁。共享凭证存在于您的环境变量、SystemProfile 文件夹或用户配置文件中。
要找到凭证,请按 Windows 键,然后输入 environment variables(环境变量)。检查 environment variables(环境变量)窗口中是否有名为 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 的变量。然后,在以下位置找到并删除与您的 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 变量相匹配的凭证:
注意: 最佳做法是在删除以下文件夹中包含的共享凭证之前,先创建这些文件夹的备份。
对于您的 SystemProfile 文件夹:
C:\Windows\System32\config\systemprofile\.aws\
C:\Windows\System32\config\systemprofile\AppData\Local\AWSToolkit\RegisteredAccounts.json
对于您的用户配置文件:
%USERPROFILE%\.aws\
%USERPROFILE%\AppData\Local\AWSToolkit\RegisteredAccounts.json
要确认您已删除这些凭证,请重启服务器,然后再次测试补丁。
排查无法搜索 Windows 更新的实例
以下错误消息表明您的实例无法搜索 Windows 更新:
- "Invoke-PatchBaselineOperation : Exception Details: An error occurred when attempting to search Windows Update.Error Message: Exception from HRESULT: 0x80240437"
- "Invoke-PatchBaselineOperation : Exception Details: An error occurred when attempting to search Windows Update.Error Message: Exception from HRESULT: 0x80072EE2"
如果您无法搜索 Windows 更新,则必须重置 Windows 更新组件。当您无法连接到 Windows 更新目录或 Windows Server Update Services (WSUS) 时,您也无法搜索 Windows 更新。
要解决这些错误,请重置 Windows 更新组件,并验证您的实例能否连接到 Windows 更新目录或 WSUS。完成以下步骤:
-
确定实例是通过代理还是通过 WSUS 连接到 Microsoft 补丁源。
-
检查您是否可以在实例中搜索 Windows 更新。
-
如果您的实例使用 WSUS 连接,则运行以下命令来检查您的 WSUS 配置:
要检查组策略,请运行以下命令:gpresult /H %USERPROFILE%\Desktop\report.html -
要检查注册表项,请运行以下命令:
Get-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU' | Select-Object AUOptions, NoAutoUpdate, UseWUServer -and- Get-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate' | Select-Object DisableWindowsUpdateAccess, WUServer, WUStatusServer -
如果您的 WSUS 配置不正确,则使用组策略或注册表项来配置 WSUS 服务器。
-
如果您的实例使用代理配置,请检查代理配置。有关代理故障排除的详细步骤,请参阅配置 SSM Agent 以使用 Windows Server 实例的代理。
注意: 如果您仅为 SSM Agent 配置代理设置,则补丁管理器无法正常运行。要正确配置系统范围的代理设置,请运行以下命令:netsh winhttp set proxy proxy-server="hostname:port" bypass-list="169.254.169.254" -
重置您的 Windows 更新组件,然后再次修补您的实例。有关说明,请参阅 Microsoft 网站上的 Windows Update - additional resources(Windows 更新 - 其他资源)。
-
如果您收到 "0x80072EE2" 错误,请验证您的服务器是否有权访问以下 URL:
http://windowsupdate.microsoft.com
https://*.windowsupdate.microsoft.com
https://update.microsoft.com
https://*.update.microsoft.com
https://windowsupdate.com
https://*.windowsupdate.com
https://download.windowsupdate.com
https://*.download.windowsupdate.com
https://download.microsoft.com
https://*.download.windowsupdate.com
https://wustat.windows.com
https://*.wustat.windows.com
https://ntservicepack.microsoft.com
如果您仍然无法搜索 Windows 更新,请查看 Windows 更新日志中是否有 "HResults" 错误。然后,根据您看到的错误代码对错误进行故障排除。
注意: 如果您使用的是 Windows Server 2016 及更高版本,则在查看日志之前运行 Get-WindowsUpdateLog PowerShell 命令。有关详细信息,请参阅 Microsoft 网站上的 Get-WindowsUpdateLog。
在以下位置查看您的 Windows 更新日志:
%windir%/WindowsUpdate.log
对于 Windows Server 托管节点,还可以在以下位置查看 AWS-RunPatchBaseline 日志:
%PROGRAMDATA%\Amazon\PatchBaselineOperations\Logs
排查无法安装的更新
要解决已下载更新的安装失败问题,请完成以下步骤:
- 查看位于 C:\Windows\Logs\CBS 中的补丁安装日志,并匹配正在运行的命令的时间戳。然后,查看日志中是否有错误消息。
- 如果补丁需要重启,则重启您的实例。
- 如果在您重启实例后仍未安装补丁,请截取屏幕截图,然后在登录屏幕上查看消息。
注意: 如果您在启动屏幕上看到以下消息,请不要重启实例:
"We couldn't complete the updates.Undoing changes.Don't turn off your computer" - 在基于组件的服务 (CBS) 日志文件中,找到 HResult 代码。然后,在 Microsoft 网站上的 Windows Update common errors and mitigation(Windows 更新常见错误和缓解措施)文档中搜索该代码。
- 重置 Windows 更新组件,然后重试安装。
排查缺少补丁的问题
有关如何对缺少补丁的问题进行故障排除的说明,请参阅为什么我的 Amazon EC2 Windows 实例在补丁管理器成功完成修补操作后仍缺少补丁?
其他故障排除步骤
如果 AWS-RunPatchBaseline 文档错误仍然存在,请完成在 Windows Server 上运行 AWS-RunPatchBaseline 时出现错误中的故障排除步骤。
- 语言
- 中文 (简体)

This article was reviewed and updated on 2026-05-05.
相关内容
AWS 官方已更新 8 个月前