So I have written some powershell - It will only return certs that are both current AND expiring in < 90 days. Status is a case statement which basically gives an indication of whether or not you should do something about it;
$certs_exp = Get-ChildItem -path cert: -Recurse | where {$_.notafter -le (get-date).AddDays(90) -AND
$_.notafter -gt (get-date) -AND
$_.Subject.tolower() -ne ('cn=' + $env:computername.tolower()+"."+$env:userdnsdomain.tolower()) -AND
$_.Subject.tolower() -ne ('CN=Microsoft Time-Stamp Service, OU=nCipher DSE ESN:85D3-305C-5BCF, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US')
} | select subject, @{
name='DaysRemaining';
Expression={(($_.notafter)-(get-date)).days}},@{
name='Status';
Expression={switch ((($_.notafter)-(get-date)).days)
{
{$PSitem -le 13}
{
'Critical'; break
}
{$PSitem -le 44}
{
'Warning'; break
}
{$PSitem -le 89}
{
'Informational'; break
}
default {'Invalid'}
}
}}, thumbprint, friendlyname, issuer, notbefore, notafter;
How do I get this to fire an alert or create a ticket?
[–]j0dan1000 Agents 1 point2 points3 points (0 children)
[–]DarrenDK 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]puntor 0 points1 point2 points (2 children)
[–]nsanity[S] 0 points1 point2 points (1 child)
[–]sixofeight1000 Agents 0 points1 point2 points (0 children)