Ever get burned by an expired certificate? Here’s a PowerShell script to check certificates on a server.
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 } }