Looking for a PowerShell script to uninstall the Rapid7 agent from Windows. I used Automox Otto AI to create one (see below), but when I run it, I keep getting “Rapid7 Insight Agent is not installed on this machine.” I checked the system, and the software is installed, so I know it exists.
======================
# Otto AI Generated Code
# ======================
# Uninstall Rapid7 Insight Agent
$uninstallString = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object {$_.DisplayName -like "*Rapid7 Insight Agent*"} | Select-Object -ExpandProperty UninstallString
if ($uninstallString) {
Write-Host "Uninstalling Rapid7 Insight Agent..."
Start-Process -FilePath "msiexec.exe" -ArgumentList "/x $uninstallString /qn" -Wait
Write-Host "Rapid7 Insight Agent has been uninstalled."
}
else {
Write-Host "Rapid7 Insight Agent is not installed on this machine."
}