script for Get-ExchangeCertificate
hello all..
i want create script check certificate exchange..
i need know when expire...
the idea create script , link nagios. step nagios can myself, compose script need help, so, lets try help.
im using command date of certificate:
get-exchangecertificate | { $_.services -like "*imap*" } | select notafter
the result is:
notafter
--------
19/11/2014 08:45:13
but i need receive date, below:
19/11/2014
how can it?
im using command date of day:
get-date -uformat "%d/%m/%y"
the result need, date:
19/11/2012
after, need compare date of day date of certificate. want receive message if 30 days remaining expire.
i appreciate me
thanks
diego
$cert = get-exchangecertificate | {$_.services -like "*imap*" } $date = $cert.notafter if($date.subtract((get-date)).days -le 30) { "critical - certificate expire in " + $date.tostring("dd\/mm\/yyyy") } else { "ok - certificate expire in " + $date.tostring("dd\/mm\/yyyy") }
Windows Server > Windows PowerShell
Comments
Post a Comment