# Startet PostgreSQL-Dienst falls nicht bereits laufend
$svc = Get-Service postgresql-x64-16 -ErrorAction SilentlyContinue
if (-not $svc) {
    Write-Host "PostgreSQL Dienst nicht gefunden. Installiert?" -ForegroundColor Red
    exit 1
}
if ($svc.Status -ne 'Running') {
    Write-Host "Starte PostgreSQL..." -ForegroundColor Yellow
    Start-Process -FilePath "powershell" -ArgumentList "-Command Start-Service postgresql-x64-16" -Verb RunAs -Wait
    Start-Sleep 2
    $svc.Refresh()
}
if ($svc.Status -eq 'Running') {
    Write-Host "PostgreSQL laeuft." -ForegroundColor Green
} else {
    Write-Host "PostgreSQL Start fehlgeschlagen." -ForegroundColor Red
}
