Hello,
I'm having issue with a simple script to monitor expiration of certificates on our NPS servers.
I wrote a simple script:
$certident=(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\AzureMFA).CLIENT_CERT_IDENTIFIER
Set-Location cert:\LocalMachine\My
$certs=(Get-ChildItem | ? Subject -eq $certident).Thumbprint
$date=get-date
$date_30=$date.AddDays(30)
foreach ($cert in $certs) {
$expiration=(Get-Item cert:\LocalMachine\My\$cert).NotAfter
if ($date_30 -ge $expiration) {
$stat1=0
}
else {
$stat1=1
}
}
if ($stat1 -eq 0) {
$mon_result = "Expiring"
}
else {
$mon_result = "Valid"
}
Write-Host "Statistic.Name1: $stat1";
Write-Host "Message.Name1: Monitoring result: $mon_result"
Whenever I run a test in SolarWinds I get the following error:
I have verified that $stat1 is of Int32 type so there shouldn't be any problem with Not being A Number. I'm pretty sure that I'm missing something simple but it's Friday and I'm probably not thinking straight.
Maybe someone will be able to point me where I'm making the mistake.