From 75587d397d7df1c32f8595332f17a5f43bab60b7 Mon Sep 17 00:00:00 2001 From: Andreas Lindemark <andreas.lindemark@liu.se> Date: Thu, 3 Apr 2025 19:58:00 +0200 Subject: [PATCH] Removed the exit at the end of the one-liner script. Since it closed the PowerShell session window. --- Windows/ZabbixAgent/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Windows/ZabbixAgent/README.md b/Windows/ZabbixAgent/README.md index c14563e..06e8740 100644 --- a/Windows/ZabbixAgent/README.md +++ b/Windows/ZabbixAgent/README.md @@ -30,7 +30,7 @@ This one-liner download and install does the following: To download, save, and execute the script, you need to temporarily change the PowerShell execution policy to allow script execution. You can do all this by using the following one-liner code in an elevated PowerShell session: ```powershell -Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force; Stop-Service -Name "Zabbix Agent 2"; $scriptPath = "C:\Windows\System32\Tasks\CheckAndStartZabbixAgent2.ps1"; try { Invoke-WebRequest -Uri "https://gitlab.liu.se/andli86/snippets/-/raw/master/Windows/ZabbixAgent/CheckAndStartZabbixAgent2.ps1" -OutFile $scriptPath -ErrorAction Stop; schtasks /create /tn "CheckAndStartZabbixAgent2" /tr "powershell.exe -File $scriptPath" /sc hourly /mo 3 /ru SYSTEM; schtasks /run /tn "CheckAndStartZabbixAgent2"; } catch { Write-Output "Failed to download the script file. Exiting prematurely."; Start-Service -Name "Zabbix Agent 2"; exit 1; } +Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force; Stop-Service -Name "Zabbix Agent 2"; $scriptPath = "C:\Windows\System32\Tasks\CheckAndStartZabbixAgent2.ps1"; try { Invoke-WebRequest -Uri "https://gitlab.liu.se/andli86/snippets/-/raw/master/Windows/ZabbixAgent/CheckAndStartZabbixAgent2.ps1" -OutFile $scriptPath -ErrorAction Stop; schtasks /create /tn "CheckAndStartZabbixAgent2" /tr "powershell.exe -File $scriptPath" /sc hourly /mo 3 /ru SYSTEM; schtasks /run /tn "CheckAndStartZabbixAgent2"; } catch { Write-Output "Failed to download the script file. Exiting prematurely."; Start-Service -Name "Zabbix Agent 2"; } ``` -- GitLab