#Requires -Version 2.0 #Requires -RunAsAdministrator <# .SYNOPSIS Uninstalls GuruRMM Legacy Agent .PARAMETER KeepConfig Keep configuration and logs (don't delete ProgramData folder) #> param( [switch]$KeepConfig ) $InstallDir = "C:\Program Files\GuruRMM" $ConfigDir = "C:\ProgramData\GuruRMM" $TaskName = "GuruRMM Agent" Write-Host "" Write-Host "Uninstalling GuruRMM Legacy Agent..." -ForegroundColor Yellow Write-Host "" # Stop and remove scheduled task try { schtasks /end /tn $TaskName 2>$null | Out-Null schtasks /delete /tn $TaskName /f 2>$null | Out-Null Write-Host "[OK] Scheduled task removed" -ForegroundColor Green } catch { Write-Host "[WARN] Could not remove scheduled task" -ForegroundColor Yellow } # Remove installation directory if (Test-Path $InstallDir) { try { Remove-Item $InstallDir -Recurse -Force Write-Host "[OK] Installation directory removed" -ForegroundColor Green } catch { Write-Host "[WARN] Could not remove $InstallDir" -ForegroundColor Yellow } } # Remove config (optional) if (-not $KeepConfig -and (Test-Path $ConfigDir)) { try { Remove-Item $ConfigDir -Recurse -Force Write-Host "[OK] Configuration removed" -ForegroundColor Green } catch { Write-Host "[WARN] Could not remove $ConfigDir" -ForegroundColor Yellow } } elseif ($KeepConfig) { Write-Host "[*] Configuration preserved at $ConfigDir" -ForegroundColor Cyan } Write-Host "" Write-Host "Uninstall complete." -ForegroundColor Green Write-Host ""