Server  $threshold = 30   #Number of days to look for  expiring certificates $deadline = (Get-Date).AddDays($threshold)   #Set deadline date Dir Cert:\LocalMachine\My | foreach { If ($_.NotAfter -le $deadline) { $_ | Select Issuer, Subject, NotAfter, @{Label= "Expires In (Days)" ;Expression={($_.NotAfter - (Get-Date)).Days}} } }   Multiple Servers $threshold = 30   #Number of days to  look for  expiring certificates  $deadline = ( Get - Date ).AddDays($threshold)   # Set  deadline date   Invoke-Command -ComputerName Srv01, Srv02 { Dir Cert:\LocalMachine\My } | foreach {   If  ($_.NotAfter -le $deadline) { $_ | Select  Issuer, Subject, NotAfter, @{Label= "Expires In (Days)" ;Expression={($_.NotAfter - ( Get - Date )).Days}} } }   Fuente: https://gallery.technet.microsoft.com/scriptcenter/Check-for-certificate-c94810e1