When I run the below script in powershell, it returns valid values for the variables. When I test it as a powershell monitor in SAM, it always returns 0 for each of the Statistic values.
I've tried putting the variable inside the "", on the write-host lines.
If I don't define the variables at the beginning as being numbers, the result in the SAM test is NaN. It's like SAM is ignoring the foreach. Is that a thing?
$HeartBeatCount = 0
$FileLineCount = 0
$Lines = Get-Content c:\windows\tracing\Trace.OLD
foreach ($Line in $Lines){
If($Line -match "Sanity"){$HeartBeatCount++}
If($Line -match "File:"){$FileLineCount++}
}
Write-Host "Message.Sanity: Sanity"
Write-Host "Statistic.Sanity: "$HeartBeatCount
Write-Host "Message.File: FIle"
Write-Host "Statistic.File: "$FileLineCount