Powershell and Expiring Certificates

A quick powershell excerpt, that will look for any certificates that expire in the next 30 days:

Get-ChildItem cert:\LocalMachine\My `
	| where { $_.notafter -le (get-date).AddDays(30) } `
	| where { $_.notafter -ge (get-date).AddDays(-1) } `
	| select subject, notafter, thumbprint

Or, in Powershell 3.0+

Get-ChildItem -Path cert: -Recurse -ExpiringInDays 30

Leave a Reply

Your email address will not be published. Required fields are marked *