Hi,
Please check to see if this works. Sorry I've got no environment to test it.
$forest = "contoso.com"
$file = "C:\temp\certs.csv"
$cred = Get-Credential ""
$out=(Get-ADForest -Identity $forest).Domains | ForEach-Object {
(Get-ADcomputer -Filter * -server $_).DNSHostName | ForEach-Object {
Invoke-Command -ComputerName $_ -credential $cred -HideComputerName -ScriptBlock {
Get-ChildItem -Path Cert:\LocalMachine -Recurse | Where-Object {$_.PSISContainer -eq $false} |
Select-Object -Property Thumbprint,Subject,Issuer,NotBefore,NotAfter
}
}
} | Select-Object -Property * -ExcludeProperty RunSpaceID,PSShowComputerName | Export-Csv -Path $file -NoTypeInformation
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.