Powershell Invoke-sqlcmd not working in Monitor Template Powershell Module

if i run from Powershell command line on server i get results.

if i run from script body i get "not defined"

i've added invoke sqlcmd on all of our Solarwinds Servers.

Top Replies

Parents
  • I format mine a little different but they run. 

    Invoke-Sqlcmd -Query "MyQuery From @Results" -ServerInstance "SQLServerName" -Database "DatabaseName"

  • @bobmarley

    I tried and get the same error. 

    Does the above script you suggested work for you in the Component Monitor?  If so, could you provide a screenshot just to see if anything stands out to me that I'm doing differently?  I've tried so many different combinations and it seems like nothing works with Invoke-sqlcmd in the component monitor even though the commands work in the Powershell application.  I called Solarwind Tech Support and was referred back to Thwack so any assistance would be helpful.  Right now i'm at the stage of "will the invoke-Sqlcmd command work at all, in any query in Component Monitor."

Reply
  • @bobmarley

    I tried and get the same error. 

    Does the above script you suggested work for you in the Component Monitor?  If so, could you provide a screenshot just to see if anything stands out to me that I'm doing differently?  I've tried so many different combinations and it seems like nothing works with Invoke-sqlcmd in the component monitor even though the commands work in the Powershell application.  I called Solarwind Tech Support and was referred back to Thwack so any assistance would be helpful.  Right now i'm at the stage of "will the invoke-Sqlcmd command work at all, in any query in Component Monitor."

Children
No Data