Powershell ADFS token-Signing certificate monitor

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"
}

Parents
  • Two Three things jump out at me:

    1. The Get-AdfsCertificate function isn't native to the OOTB PowerShell modules.  You'll most likely need to import that module at/near the top of your script with Import-Module -Name ADFS.  If this is running from the SolarWinds Server and not in a remote mode, you'll need to add the necessary Windows Feature (ADFS-Federation).  I haven't worked with ADFS before, but this is where I'm thinking you'd need to go)
    2. You never "exit" the call with exit($ExitStatus[$ExitCode]) which is what I'm assuming you are trying to do based on one of my (very) old blog posts about it.
    3. And yes - "Statistic" is spelled incorrectly.
  • Added the Import-module. No Change

    By "not in a remote mode" are you referring to the Execution Mode for the template? It's set for remote.

    I changed the "$ExitStatus = 'Up"" to "Exit 0;"

Reply Children
No Data