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

如何远程卸载AWS Windows实例上的CloudHealth旧版代理?

旧版CloudHealth代理强制卸载方案

针对旧版CloudHealth代理卸载失败的问题,以下是经过验证的单实例/批量卸载方案:

1. 定位正确的MSI产品GUID(解决注册表路径缺失问题)

Windows 64位系统中,32位应用的卸载注册表项默认存放在HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall而非常规路径。执行以下步骤:

  • 以管理员身份打开PowerShell,运行命令查找代理的GUID:
$uninstallPaths = @(
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

foreach ($path in $uninstallPaths) {
    if (Test-Path $path) {
        Get-ChildItem $path | ForEach-Object {
            $props = Get-ItemProperty $_.PSPath
            if ($props.DisplayName -like "*CloudHealth Agent*") {
                Write-Host "Found Agent GUID: $($_.PSChildName)"
            }
        }
    }
}
  • 拿到GUID后,执行静默卸载命令:
msiexec /x "{找到的GUID}" /quiet /norestart

若仍失败,添加/forcerestart参数强制重启完成卸载。

2. 利用Win32_CimInstance执行卸载(绕过注册表缺失问题)

如果注册表中无对应项,但控制面板可见代理,可通过WMI直接调用卸载:

$agent = Get-CimInstance Win32_Product | Where-Object {$_.Name -match "CloudHealth Agent"}
if ($agent) {
    $uninstallResult = $agent.Uninstall()
    # 返回值0表示成功,非0为失败
    Write-Host "Uninstall result code: $($uninstallResult.ReturnValue)"
}

注意:Win32_Product会触发MSI自检修复,若代理文件已损坏,需结合后续手动清理步骤。

3. 指定完整MSI路径执行卸载(解决安装包无法打开问题)

你提到的MSI包存在但无法打开,大概率是权限或路径引用问题,尝试用管理员身份执行完整路径命令:

msiexec /x "C:\Users\Administrator\AppData\Local\Downloaded Installations\{875BF87C-67C8-4E38-ACAE-61EEC129430B}\CloudHealthAgent.msi" /quiet

若当前用户非Administrator,替换为实际用户路径。

4. 批量卸载的AWS State Manager脚本优化

针对3000+实例,建议使用以下PowerShell脚本通过State Manager执行,自动适配系统位数、检测代理状态并执行对应卸载逻辑:

# 停止CloudHealth Agent服务
Stop-Service -Name "CloudHealthAgent" -Force -ErrorAction SilentlyContinue

# 尝试通过注册表查找GUID卸载
$uninstallPaths = @(
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

$agentGuid = $null
foreach ($path in $uninstallPaths) {
    if (Test-Path $path) {
        $agentKey = Get-ChildItem $path | Where-Object {
            (Get-ItemProperty $_.PSPath).DisplayName -like "*CloudHealth Agent*"
        }
        if ($agentKey) {
            $agentGuid = $agentKey.PSChildName
            break
        }
    }
}

if ($agentGuid) {
    Start-Process msiexec.exe -ArgumentList "/x `"$agentGuid`" /quiet /norestart" -Wait -NoNewWindow
    exit 0
}

# 注册表无项时,尝试Win32_CimInstance卸载
$agent = Get-CimInstance Win32_Product | Where-Object {$_.Name -match "CloudHealth Agent"}
if ($agent) {
    $uninstallResult = $agent.Uninstall()
    exit $uninstallResult.ReturnValue
}

# 最后执行手动清理
Remove-Item -Path "C:\Program Files\CloudHealth" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files (x86)\CloudHealth" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\CloudHealthAgent" -Recurse -Force -ErrorAction SilentlyContinue

exit 0

将该脚本保存为PowerShell文件,通过State Manager的AWS-RunPowerShellScript文档批量执行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 18:22:21