#Requires -RunAsAdministrator [CmdletBinding()] param() $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $host.UI.RawUI.BackgroundColor = 'Black' $host.UI.RawUI.ForegroundColor = 'White' if ($host.UI.RawUI.WindowSize) { try { $host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size(60,20) } catch {} } Clear-Host function Write-Header { Write-Host "" Write-Host " ╔══════════════════════════════════════════════════╗" -ForegroundColor Cyan Write-Host " ║ ║" -ForegroundColor Cyan Write-Host " ║ zurichtech — RMM Agent Setup ║" -ForegroundColor Cyan Write-Host " ║ ║" -ForegroundColor Cyan Write-Host " ╚══════════════════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" } function Write-Step($n, $total, $text, $status = $null) { $icon = if ($status -eq 'ok') { '✓' } elseif ($status -eq 'skip') { '–' } else { '…' } $col = if ($status -eq 'ok') { 'Green' } elseif ($status -eq 'skip') { 'DarkGray' } else { 'Yellow' } Write-Host (" [{0}/{1}] {2,-36} " -f $n, $total, $text) -NoNewline Write-Host $icon -ForegroundColor $col } function Write-Footer($success) { Write-Host "" if ($success) { Write-Host " ╔══════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host " ║ ✓ Installation erfolgreich abgeschlossen! ║" -ForegroundColor Green Write-Host " ╚══════════════════════════════════════════════════╝" -ForegroundColor Green } else { Write-Host " ╔══════════════════════════════════════════════════╗" -ForegroundColor Red Write-Host " ║ ✗ Fehler bei der Installation. ║" -ForegroundColor Red Write-Host " ╚══════════════════════════════════════════════════╝" -ForegroundColor Red } Write-Host "" Write-Host " Dieses Fenster schliesst sich in 5 Sekunden..." -ForegroundColor DarkGray Start-Sleep 5 } $cfg = @{ AgentVersion = 'v2.10.0' Arch = 'windows-amd64' ApiUrl = 'https://api.zurichtech.ch' ClientId = '2' SiteId = '2' AgentType = 'workstation' AuthToken = '8299abe262cca910218f7e06602be0b8a77b880360a009d6109a156e4fa24a74' Power = $true; Rdp = $true; Ping = $true } $agentExe = "tacticalagent-$($cfg.AgentVersion)-$($cfg.Arch).exe" $downloadUrl = "https://github.com/amidaware/rmmagent/releases/download/$($cfg.AgentVersion)/$agentExe" $tmpFile = Join-Path $env:TEMP $agentExe Write-Header Write-Step 1 5 'Pruefe bestehende Installation...' if (Get-Service 'tacticalrmm' -ErrorAction SilentlyContinue) { Write-Step 1 5 'Bereits installiert — kein Update noetig.' 'skip' Write-Footer $true; exit 0 } Write-Step 1 5 'Pruefe bestehende Installation...' 'ok' Write-Step 2 5 'Setze AV-Exclusions...' try { if ((Get-MpComputerStatus -ErrorAction Stop).AntivirusEnabled) { @('C:\Program Files\TacticalAgent','C:\Program Files\Mesh Agent','C:\ProgramData\TacticalRMM') | ForEach-Object { Add-MpPreference -ExclusionPath $_ -ErrorAction SilentlyContinue } } } catch {} Write-Step 2 5 'Setze AV-Exclusions...' 'ok' Write-Step 3 5 'Pruefe Netzwerkverbindung...' $apiHost = ([Uri]$cfg.ApiUrl).Host $ok = $false 1..5 | ForEach-Object { if (-not $ok) { if ((Test-NetConnection $apiHost -Port 443 -WarningAction SilentlyContinue).TcpTestSucceeded) { $ok = $true } else { Start-Sleep 5 } }} if (-not $ok) { Write-Step 3 5 'Netzwerk nicht erreichbar!' 'err'; Write-Footer $false; exit 1 } Write-Step 3 5 'Pruefe Netzwerkverbindung...' 'ok' Write-Step 4 5 'Lade Agent herunter...' try { Invoke-WebRequest -Uri $downloadUrl -OutFile $tmpFile -UseBasicParsing Start-Process -FilePath $tmpFile -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES' -Wait Start-Sleep 5 Write-Step 4 5 'Lade Agent herunter...' 'ok' } catch { Write-Step 4 5 'Download fehlgeschlagen!' 'err'; Write-Footer $false; exit 1 } Write-Step 5 5 'Installiere RMM Agent...' $installArgs = @('-m','install','--api',$cfg.ApiUrl,'--client-id',$cfg.ClientId, '--site-id',$cfg.SiteId,'--agent-type',$cfg.AgentType,'--auth',$cfg.AuthToken) if ($cfg.Power) { $installArgs += '--power' } if ($cfg.Rdp) { $installArgs += '--rdp' } if ($cfg.Ping) { $installArgs += '--ping' } try { Start-Process 'C:\Program Files\TacticalAgent\tacticalrmm.exe' -ArgumentList $installArgs -Wait Write-Step 5 5 'Installiere RMM Agent...' 'ok' Write-Footer $true } catch { Write-Step 5 5 'Installation fehlgeschlagen!' 'err' Write-Footer $false; exit 1 } finally { Remove-Item $tmpFile -ErrorAction SilentlyContinue }