PowerShell - Get List of x509 Certificates from text list of servers/computers
- Jon Boyette
- Jan 11, 2022
- 1 min read
Save this as a named.ps1, populate c:\temp\servers.txt, with workstations or servers, checks Get-ChildItem Cert:\LocalMachine\root
$a = Get-Content C:\temp\servers.txt
Invoke-Command -ComputerName $a -Scriptblock{
Get-ChildItem Cert:\LocalMachine\root | Where-Object {$_ -is [System.Security.Cryptography.X509Certificates.X509Certificate2] -and $_.NotAfter -lt (Get-Date)} | Select-Object -Property PSComputerName,FriendlyName,Subject,NotBefore,NotAfter,Issuer,Thumbprint
} | Export-Csv c:\temp\CertificatesFromListedServers.csv
Comments