Hi im having trouble to run this powershell command via custom sensor ...

running it with the powershellscriptrunner.exe i get only empty results - that seems to time out

$cmd = Invoke-Sqlcmd  -ServerInstance instance  -Database  db -Query "SELECT * FROM tablexy where replicationsuccess = y/n

$result = 1

try {
      if ($cmd.value -eq "N") {
        $result=0
       $resulttxt="ok -$($cmd.value)-"
      } 
      else {
       $resulttxt="Problem -$($cmd.value)-"
       $result=2
      }
} 
catch {
    $resulttxt="Problem catch"
    $result=1
	return
}
Write-host  "<prtg><result><channel>Replication</channel><value>$result</value><showChart>1</showChart><showTable>1</showTable><LimitMinError>0</LimitMinError><LimitMaxError>0</LimitMaxError></result><Text>$resulttxt</Text></prtg>" 

result via powershellscriptrunner:

<prtg><result><channel>Replication</channel><value>2</value><showChart>1</showChart><showTable>1</showTable><LimitMinError>0</LimitMinError><LimitMaxError>0</LimitMaxError></result><Text>Problem --</Text></prtg>

result via powershell:

<prtg><result><channel>Replication</channel><value>2</value><showChart>1</showChart><showTable>1</showTable><LimitMinError>0</LimitMinError><LimitMaxError>0</LimitMaxError></result><Text>Problem --</Text></prtg>

Article Comments