If you need to get all certificates, from a list of remote computers, you can use this script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
$Servers = "kennethdalbjerg-dc01", "kennethdalbjerg-dc02", "kennethdalbjerg-exch01", "kennethdalbjerg-fs01" $Results = @() $Results = Invoke-Command -cn $Servers { $Certs = @{} | Select Certificate,Expired $Cert = Get-ChildItem Cert:\LocalMachine\My If($Cert){ $Certs.Certificate = $Cert.subject $Certs.Expired = $Cert.NotAfter } Else{ $Certs.Certificate = " - " $Certs.Expired = " - " } $Certs } | Select-Object @{n='ServerName';e={$_.pscomputername}},Certificate,Expired #Display results in console $Results | Sort-Object Expired -Descending #Save results to CSV file $Results | Sort-Object Expired -Descending | Export-Csv -Path C:\users\$env:username\desktop\cert_results.csv -NoTypeInformation -Force #Open results in new window $Results | Sort-Object Expired -Descending | Out-GridView -Title "Final results" |