Issue
Code backup
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
##########################
|
||||
# Writer: Claudio Boggian
|
||||
# Company: PAL s.r.l.
|
||||
#-------------------------
|
||||
# Date: 2025-12-03
|
||||
# v: 1.0
|
||||
# Reason: Emission
|
||||
#-------------------------
|
||||
##########################
|
||||
|
||||
param(
|
||||
[string]$CertName = "SQL SSL Cert"
|
||||
)
|
||||
|
||||
$cert = Get-ChildItem Cert:\LocalMachine\My |
|
||||
Where-Object { $_.FriendlyName -eq $CertName } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $cert) {
|
||||
Write-Output "CRITICAL - Certificato '$CertName' non trovato"
|
||||
exit 2
|
||||
}
|
||||
|
||||
$now = Get-Date
|
||||
$expires = $cert.NotAfter
|
||||
$daysLeft = ($expires - $now).Days
|
||||
|
||||
if ($daysLeft -lt 0) {
|
||||
Write-Output "CRITICAL - Certificato '$CertName' SCADUTO il $($expires)"
|
||||
exit 2
|
||||
}
|
||||
|
||||
if ($daysLeft -lt 7) {
|
||||
Write-Output "CRITICAL - Certificato '$CertName' scade tra $daysLeft giorni (il $($expires))"
|
||||
exit 2
|
||||
}
|
||||
|
||||
if ($daysLeft -lt 15) {
|
||||
Write-Output "WARNING - Certificato '$CertName' scade tra $daysLeft giorni (il $($expires))"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Output "OK - Certificato '$CertName' valido fino al $($expires) ($daysLeft giorni rimanenti)"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user