Powershell script monitor

We have a very basic PS script to check if a port is listening. The script works fine when ran directly on the target machine but is returning error codes when running in Solarwinds.

Script: $Test=Get-NetTCPConnection -State Listen,Established
if($Test -like '*8080*') { Write-Host '0' | Exit 0} else { Write-Host '1' | Exit 1}


 Get Output Failed:
Output: ==============================================
but if ran on the server, it returns a up status.
Windows Powershell monitor settings:
script arguments: c:\temp *is this correct?
Execution mode: Local host - have tried both local and remote but neither gets the results I am expecting