I have a script that runs fine locally on our ADFS server. However, when I try to create a Powershell component monitor I get an unknown status with no other details. I have gone over as many articles i can find but I'm still having issues and was hoping someone could offer guidance. I plan to use the $CertType
variable as an argument later for other certs . The account being used has admin rights and ports are open. Execution is set to "remote"
My Code:
$ExitStatus = @{ "Up" = 0; "Down" = 1; "Warning" = 2; "Critical" = 3; "Unknown" = 4 ; } $CertType = 'Token-Signing' $CertThumb = ( Get-AdfsCertificate | Where-Object {$_.CertificateType -eq $CertType} ).thumbprint $TodayDate = Get-Date -Format "MM/dd/yyyy" $CertExpDate = ( Get-AdfsCertificate -Thumbprint $CertThumb ).Certificate.NotAfter $AlertDays = 30 $CertDaysLeft = New-TimeSpan -Start $TodayDate -End $CertExpDate $Stat = $CertDaysLeft.Days if ($Stat -gt $AlertDays -and $CertDaysLeft.days -gt 0) { Write-Host "Message: There are $Stat days until $CertExpDate for $CertType Certificate" Write-Host "Satistic: $Stat" $ExitStatus = 'Up" }