I am trying to run a Powershell monitor that outputs data from a SQL select statement, so that I can use the data in my alert bodies.
The below script runs against my database, and outputs a statistic value in char form.
$results = Invoke-Sqlcmd -Query "set nocount on;begin select ip.policyno as [Stat1]
from i1.dbo.DD_InstalmentPlan ip where ip.Status IN ('L', 'F', 'D', 'N')
end " -ServerInstance "********************" -Username "*********" -Password "*******"
$statistic1 = $results | select -expand Stat1
write-host "Statistic.Stat1: $statistic1";
How do you get the output to be critical when it outputs a char rather than an integer?
Thanks