Ad Widget

Collapse

Running Powershell Script as trigger action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xaviermace
    Junior Member
    • Feb 2022
    • 4

    #1

    Running Powershell Script as trigger action

    I feel like I have to be missing something painfully obvious here. I've got some eventlog items setup and working great. However, I want a trigger action to run a Powershell script on the host. I for the life of me can't figure out how to format it so Zabbix is properly handling the path. This works when directly run on the host:

    powershell.exe -ExecutionPolicy Unrestricted -file "C:\Program Files\Zabbix Agent 2\zabbix_scripts\mytestscript.ps1"

    I've tried enclosing the whole thing in both single quotes and double quotes. I've tried escaping just the double quotes or both the double quotes and the backslashes. It launches Powershell (as far as I can tell), but the path to the script isn't being passed correctly so it just errors out saying the file doesn't exist. Running Zabbix 6.4.1.
  • Anonymouse
    Junior Member
    • May 2023
    • 2

    #2
    Here's an example of one that works for me.
    UserParameter=ADHealthChecks,powershell.exe -NoProfile -ExecutionPolicy bypass -File "C:\foldername\scriptname.ps1" - userparameter is the name of the key for your script, which goes in the trigger.

    Comment

    Working...