Check for expiring certificates
Ever get burned by an expired certificate? Here’s a Powershell script to checks certs on a windows box.
Clear-Host $threshold = 365 #Number of days to look for expiring certificates $deadline = (Get-Date).AddDays($threshold) #Set deadline date Invoke-Command -ComputerName server01 { Dir Cert:\LocalMachine\My } | foreach { If ($_.NotAfter -le $deadline) { $_ | Select PSComputerName, Subject, NotAfter, @{Label="Expires In (Days)";Expression={ ($_.NotAfter - (Get-Date)).Days}} | ft }}