Hi,

I have created a Powershell script to check for all certificates which are to 
expire within 45 and 90 days on any machine it is run against. It creates 
application log entries for each certificate about to expire in the specified 
date ranges

I am struggling to put this into a management pack.


Powershell script:
$strWarningDays = 90
$strErrorDays=45

$strLogSourceExists = Get-Eventlog -logName Application | select-object Source 
-Unique
if (! $strLogSourceExists)
{
  New-Eventlog -LogName Application -Source CertExpiry45Days
  New-Eventlog -LogName Application -Source CertExpiry90Days
}

$strCerts45 = @(get-childitem -Path cert:\* -Recurse | where { $_.notafter -le 
(get-date).AddDays($strErrorDays) -AND $_.notafter -gt (get-date)} | select 
subject,thumbprint,friendlyname,NotAfter)
$strCerts90 = @(get-childitem -Path cert:\* -Recurse | where { $_.notafter -le 
(get-date).AddDays($StrWarningDays) -AND $_.notafter -gt (get-date)} | select 
subject,thumbprint,friendlyname,NotAfter)

foreach($strCertificate in $strCerts45)
{
  write-Eventlog -LogName Application -Source "CertExpiry45Days" -EntryType 
Error -EventId 100 -Message $StrCertificate
}
$str90Days = @(Compare-Object $strCerts45 $strCerts90).InputObject
foreach($str90DayCert in $str90Days)
{
   write-Eventlog -LogName Application -Source "CertExpiry90Days" -EntryType 
Warning -EventId 100 -Message $Str90DayCert
}

Now I want to put this into a management pack does anyone have some examples so 
I can distribute this out to one of my hosted customers? thks



Peter Hakesley | Monitoring & Automation Technical Lead Engineer, Data Centre 
Services

t: +44(0)845 155 6556 ext: 4006
e: [email protected] | w: www.scc.com<http://www.scc.com/>
a: SCC, CV1, Cole Valley, 20 Westwood Avenue, Tyseley, Birmingham B11 3RZ






Reply via email to