Ad Widget

Collapse

Zabbix Agent is returning "Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dude_in_Blue
    Junior Member
    • May 2022
    • 5

    #1

    Zabbix Agent is returning "Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized

    Hello Everyone,

    I am having an issue with getting zabbix agent to run a powershell script for an sql query.

    When I am running the command manually I am getting the expected output with no issue, but when the zabbix agent is running the command or If I trigger it using zabbix_get I am getting the following error

    Code:
    Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized as the name of a
    cmdlet, function, script file, or operable program. Check the spelling of the
    name, or if a path was included, verify that the path is correct and try again.
    At C:\Windows\zabbix_agents_3.0.0.windows\bin\state.p s1:10 char:17
    + $colItems = Invoke-Sqlcmd -ServerInstance xyz -Database
    "abc" ...
    + ~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Invoke-Sqlcmd:String) [], Comma
    ndNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    
    {
    "data":[
    
    ]
    }
    I'am having no issues with other servers monitored by the same proxy and I am getting the proper output(both when executed manually and through zabbix). So where could the issue be present?

    The following UserParameters are returning this error
    Code:
    UserParameter=Backup.discovery, powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\Backup. ps1
    UserParameter=Backup.time[*], powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\Backup. ps1 $1 "$2"
    
    UserParameter=session.discovery, powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\session .ps1
    UserParameter=session.time[*], powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\session .ps1 $1 "$2"
    
    UserParameter=conn, powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\connect ion.ps1
    
    UserParameter=db.discovery, powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\state.p s1
    UserParameter=db.state[*], powershell -NoProfile -ExecutionPolicy Bypass -File c:\windows\zabbix_agents_3.0.0.windows\bin\state.p s1 $1 "$2"
    The system details are
    OS: Windows 2012
    Agent Version: 3.0.0
    Proxy Version: 3.0.4
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Windows is not my thing, but... some environment values missing? I know these exist even in windows..

    Comment

    • Dude_in_Blue
      Junior Member
      • May 2022
      • 5

      #3
      Hello All,

      Just an update,

      Our Windows Team checked and found that the server with this issue did not have windows managment framework 5.1 installed while the servers without this issue did have it installed. They installed it and the issue was solved and data is polling properly. But that being said I dont know specifically what was missing and what that framework added to fix this.

      Comment

      Working...