We have a PS script works fine in ISE, harvests some data from a web page regarding remaining days on a licence. we want to use the integer as the statistic value so we can set a warning and critical level in the template.
the issue is we get 'Not Defined' for the statistic output, not sure what we are missing.
$infourl = "http://${NodeDNS}:8989/GetInfo"
[xml]$blob = Invoke-WebRequest -URI $infourl | Select -expand Content
if ($blob) { #check licenses if there was a response from the license service.
$days=99
$daysleft = 99
foreach ($lic in $blob.LicensingService.AvailableLicenses.LicenseType) {
$days = $lic.License.minDaysLeft
foreach ($daybit in $days) {
if ([int]$daybit -lt $daysleft -and [int]$daybit -gt 0) {
$daysleft = $daybit
}
}
}
Write-Host 'Statistic: '$daysleft
}
Have turned of IE first run Wizard in GP, still get not defined.
Any ideas? Tried various combinations to no avail.