diff --git a/Deploy-ZabbixAgent2.ps1 b/Deploy-ZabbixAgent2.ps1 index 7261f51..050782a 100644 --- a/Deploy-ZabbixAgent2.ps1 +++ b/Deploy-ZabbixAgent2.ps1 @@ -167,7 +167,14 @@ if (-not $existingService) { Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\Zabbix Agent 2" -Recurse -Force -ErrorAction SilentlyContinue & $ExePath --config "$ConfPath" --install Start-Sleep -Seconds 2 + Start-Service "Zabbix Agent 2" } +else { + # Force a restart so any newly written config or metadata loads into RAM immediately + Restart-Service "Zabbix Agent 2" -Force +} + +Set-Service -Name "Zabbix Agent 2" -StartupType Automatic Start-Service "Zabbix Agent 2" -ErrorAction SilentlyContinue Set-Service -Name "Zabbix Agent 2" -StartupType Automatic