Ad Widget

Collapse

Problem with remote powershell script execution

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spider
    Junior Member
    • Sep 2014
    • 4

    #1

    Problem with remote powershell script execution

    Hi!

    I would like to find some installed application in remote computers.
    I have a basic script for this:

    $var=gwmi win32_product | where{$_.name -match "application name"}
    if($valt -eq $null}
    {
    echo "0"
    }
    else
    {
    echo "1"
    }

    I set the execution policy in powershell to unrestricted.
    The firewall is disabled and the zabbix agent is alive in the remote hosts
    and the remote command execution is enabled in client side

    I try to send a remote command with zabbix_get from zabbix server
    and the answer is "zbx_notsupported"

    this is the command which does not work:
    zabbix_get -s remotehost -k system.run['powershell.exe -noprofile -Executionpolicy bypass -file //remote_server/share/script.ps1']

    the remote share is shared for everybody and the NTFS permission is: everybody "full controll"

    if I run this script in a local computer once, it works
    after that, the zabbix_get command is working
    I don't understand why...

    I know probably it isn't a zabbix's problem,
    but I would like to understand what the problem is
    is somebody could help me in this?
    Thx a lot!
  • tchjts1
    Senior Member
    • May 2008
    • 1605

    #2
    Have you added the appropriate UserParameter to the zabbix_agentd.conf file on the host, then restarted the agent?

    For instance, I monitor rotational log files on several hosts using a PowerShell script, so this is my entry for UserParameter:

    Code:
    # Script for retrieving rotational log file names and sizes
    UserParameter=file.discovery,powershell -File "D:\apps\zabbix\scripts\FileSize.ps1"

    Comment

    • spider
      Junior Member
      • Sep 2014
      • 4

      #3
      Thanks for the reply!

      If I set the user parameter in conf file:
      UserParameter=application.finder,powershell -File "c:\temp\zabbix\teszt.ps1"

      And I use this command in zabbix server:
      zabbix_get -s hostname -k application.finder
      answer: "ZBX_NOTSUPPORTED"

      zabbix agent is running with "Local system" account.

      The operation system in the client side is: Windows 7 Professional x64
      The agent version is: 2.0.4

      Any idea?

      Comment

      Working...