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.