Ad Widget

Collapse

system.run powershell command with Zabbix Agent Active

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cristianssenn
    Junior Member
    • May 2021
    • 1

    #1

    system.run powershell command with Zabbix Agent Active

    Hello gents.

    I just wanted to know if there is a limitation of Zabbix in using a key with a powershell command, like:
    Type: Zabbix Agent (active)
    Key: system.run[powershell.exe -command "get-ClusterGroup | Select Name | ConvertTo-Json -Compress"]
    Info: Text


    The only value that I receive is:
    get-ClusterGroup | Select Name | ConvertTo-Json -Compress

    On the host, the command returns the json with the correct values.

    PS: I tried with different combinations of quota, double quota and escape characters and none worked. But, maybe I miss something...

    PS2: I'm not interested in using a PS script deployed on each host.

    Thanks.
  • lgros
    Junior Member
    • Jun 2023
    • 2

    #2
    I don't know if this is still relevant, but this is how I did it
    system.run[[powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "@{data=@(Get-ClusterGroup |Where-Object {$_.Name -ne 'Available Storage' -and $_.Name -ne 'Cluster Group'}|Select-object @{n='{#ROLENAME}';e={$_.Name}},@{n='{#ROLEID}';e={ $_.Id}})}|ConvertTo-Json -Compress"]]
    the double square brackets are valid.

    Comment

    Working...