Hi guys,
I am running the below powershell script to pull the number of days before our CA certs expire.
$threshold = 9999 #Number of days to look for expiring certificates $deadline = (Get-Date).AddDays($threshold) #Set deadline date [string]$ServerName = "test-server" #Leave this blank when utilizing this in PRTG Invoke-Command -ComputerName $ServerName { Dir Cert:\LocalMachine\My } | foreach { If ($_.NotAfter -le $deadline) { $_ | Format-List Issuer, @{Label="Expires In (Days)";Expression={($_.NotAfter - (Get-Date)).Days}} ;} elseif ($_.NotAfter -ge $deadline) {Write-host $deadline ":All Certificates are NOT expiring within $threshold days."} } The Expected output looks like this: Issuer : CN=test-serverCACERT Expires In (Days) : 43 Issuer : CN=test.serverCACERT Expires In (Days) : 43
Currently, PRTG is only executing the script and not displaying any of the outputs. Am I able to format the output so that PRTG will create channels based on the issuer, and a value based on the Expires In (Days)?
Add comment