From d632f0d383b000424395d36234bca6e2b913c277 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 18 Nov 2026 10:51:21 +0100 Subject: [PATCH] fix: keep the installation when the first NetBox sync fails The Intune installation state now only depends on the installed files and the scheduled task; a temporary NetBox or network error during the first sync no longer fails the installation. Co-Authored-By: Claude Opus 5.5 --- scripts/install.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index e81ea70..9662c88 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -26,6 +26,14 @@ $principal = New-ScheduledTaskPrincipal -UserId 'S-1-5-18' -LogonType ServiceAcc $settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 15) Register-ScheduledTask -TaskName 'NetBox Windows Agent' -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null & $agentPath --config $configPath -if ($LASTEXITCODE -ne 0) { throw "Die erste NetBox-Synchronisation ist mit Exitcode $LASTEXITCODE fehlgeschlagen." } -Write-Host 'NetBox Windows Agent wurde erfolgreich installiert und synchronisiert.' +$syncExitCode = $LASTEXITCODE +if ($syncExitCode -ne 0) { + Write-Warning "Der Agent wurde installiert, aber die erste NetBox-Synchronisation ist mit Exitcode $syncExitCode fehlgeschlagen. Die geplante Aufgabe versucht es erneut." +} else { + Write-Host 'Die erste NetBox-Synchronisation war erfolgreich.' +} +if (-not (Test-Path -LiteralPath $agentPath)) { throw 'Installation fehlgeschlagen: agent.exe wurde nicht installiert.' } +if (-not (Test-Path -LiteralPath $configPath)) { throw 'Installation fehlgeschlagen: config.json wurde nicht installiert.' } +if (-not (Get-ScheduledTask -TaskName 'NetBox Windows Agent' -ErrorAction SilentlyContinue)) { throw 'Installation fehlgeschlagen: Die geplante Aufgabe fehlt.' } +Write-Host 'NetBox Windows Agent wurde erfolgreich installiert.' exit 0