I've got a script that counts the number of process running on my application server. When I run the script on the server itself, it returns the right output. However, when I try to run the script via solarwinds (with a domain admin credential) it returns me the output below. What is going wrong?
Via Solarwinds:
Message.Statistic: Harmony is NOT correctly running
Statistic.Statistic: NaN
Local on the server:
Message: Harmony is correctly running
Statistic: 2
SCRIPT:
$process = "harmony_server"
$log = get-process $process
$Gevonden = Select-String -InputObject $log -Pattern $process -AllMatches
$countprocess = $Gevonden.Matches.Count
If ($countprocess -eq 2)
{
$msg = "Harmony is correctly running"
}
Else
{
$msg = "Harmony is NOT correctly running"
}
#Message in Solarwinds
Write-Host "Message: $msg"
#Statistic Value in Solarwinds
Write-Host "Statistic: $countprocess"