# IT Nexus Agent deinstallieren (als Admin ausführen!)
Write-Host "Stoppe IT Nexus Agent Service..." -ForegroundColor Yellow

# Dashboard-Prozess killen
Get-Process -Name "IT-Nexus-Agent" -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Milliseconds 500

# Service stoppen
net stop "IT Nexus Agent" 2>$null
Start-Sleep -Seconds 2

# Service löschen
sc.exe delete "IT Nexus Agent"
Start-Sleep -Seconds 1

# Autostart entfernen
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "IT Nexus Agent" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "IT Nexus Agent" -ErrorAction SilentlyContinue

# Alten Installations-Ordner falls vorhanden entfernen
if (Test-Path "C:\Program Files\IT Nexus Agent") {
    Remove-Item "C:\Program Files\IT Nexus Agent" -Recurse -Force
    Write-Host "Installations-Ordner entfernt" -ForegroundColor Green
}

# Status-Datei bleibt (config.json behalten, status.json löschen)
Remove-Item "C:\ProgramData\IT Nexus Agent\status.json" -ErrorAction SilentlyContinue
Write-Host "status.json entfernt"

Write-Host ""
Write-Host "Agent vollstaendig entfernt. Jetzt setup.exe ausfuehren!" -ForegroundColor Green
Write-Host "Druecke Enter zum Schliessen..." -ForegroundColor Gray
Read-Host
