1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
sl cert: $MaxDays = 30 $MachineName = $env:COMPUTERNAME Get-ChildItem -Recurse | where { $_.notafter -le (get-date).AddDays($MaxDays) -AND $_.notafter -gt (get-date).AddDays(-$MaxDays) } | Select-Object @{Name="MachineName";Expression={$MachineName}}, @{Name="Location";Expression={$_.PSParentPath}}, Thumbprint, NotBefore, NotAfter, Subject, Issuer, FriendlyName, Extensions | Format-List |
Note: The above script will notify you if a certificate has expired in the last 30 days or will be expiring in the next 30 days. To change the amount of days to check to 60, for example, update the line $MaxDays = 30 to $MaxDays = 60
When running PowerShell scripts, also ensure that the proper execution policy is set.