3 Replies Latest reply on Apr 11, 2018 9:04 AM by ajiwanand

    Powershell script off a triggered alert not working

    ajiwanand

      I've created a powershell script that restarts a custom service if it is down, this works when running locally in multiple ways however whenever I use solarwinds I am unable to get the script to run.

       

      I'm unsure if it is permissions however I did try changing the account of the "Solarwinds Alerting Service V2" to a local admin account as well as confirmed (by opening powershell as the user) that they can run the script.

       

      I've confirmed hte script works locally as well as it only seems to fail when launching a program.

       

      Trigger action: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -Command "C:\SolarWindsScripts\connector.ps1 ${Nodename} ${servicename} start"

       

      Script:

       

      param([string]$server,[string]$servicename,[string]$action)

       

       

      $user = 'username'

      $password = 'password'

       

       

      plink.exe $server -l $user -pw $password -t "echo -e '$password\n' | sudo -S /etc/init.d/$servicename $action"

       

       

      I've confirmed the powershell is launching, it takes hte arguments fine, seems to execute however the external program (plink.exe) does not get executed.

       

      What can i do to fix this?

       

      PS: Ignore the script arguments I just sanitized it. I was using plain text, but plan to use variables as well.