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

Popular posts from this blog

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source