Update Deploy-ZabbixAgent2.ps1

Update zabbix service restart
This commit is contained in:
2026-09-10 16:56:34 +10:00
parent 54fb18eb3b
commit 58adda81a8

View File

@@ -167,7 +167,14 @@ if (-not $existingService) {
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\Zabbix Agent 2" -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\Zabbix Agent 2" -Recurse -Force -ErrorAction SilentlyContinue
& $ExePath --config "$ConfPath" --install & $ExePath --config "$ConfPath" --install
Start-Sleep -Seconds 2 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 Start-Service "Zabbix Agent 2" -ErrorAction SilentlyContinue
Set-Service -Name "Zabbix Agent 2" -StartupType Automatic Set-Service -Name "Zabbix Agent 2" -StartupType Automatic