Ad Widget

Collapse

Powershell script runs and returns 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bug_sson
    Junior Member
    • Aug 2018
    • 7

    #1

    Powershell script runs and returns 1

    Hello everyone,

    I'm trying to run a powershell script through the agent, to return a percentage. The script should return a raw number that represents a percentage, no decimals, no headers, not even the "blank space" on the headers that would return with the ft -hide option nor the "%" symbol. Just the number.

    After enabling remote commands on the agent config, I'm running the script with the following key on an item:

    system.run[powershell.exe -NoLogo -NonInteractive -ExecutionPolicy Bypass -File " C:\zabbix\scripts\scripttest.ps1",nowait]

    The item is enabled, but it's returning a constant value of 1. I believe it's the exit code, and 1 should be "the script ran successfuly" or something alike, but I'd like to receive the script output, yet, I don't know how to make zabbix return the value. Has anyone got to deal with this issue?

    Thanks in advance!
  • androponia
    Junior Member
    • Jan 2019
    • 18

    #2
    Sure that have the right permissions on the file?

    Comment

    • ComputerHabit
      Member
      • Jun 2020
      • 46

      #3
      Is it one of those thing where you need to use the . and a space before the command?

      Like this:
      . "C:\zabbix\scripts\scripttest.ps1"

      Comment

      Working...