get-aduser -SearchBase $ou -Filter * -Properties displayname,usercertificate |ForEach-Object{ $displayname = $_.displayname $_|select -ExpandProperty usercertificate | ForEach-Object{ $cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]$_ [pscustomobject]@{ DisplayName = $displayname IssuedTo = $cert.Subject IssuedBy = $cert.Issuer IntendedPurpose = $cert.EnhancedKeyUsageList ExpiredData = $cert.NotAfter SerialNumber = $cert.SerialNumber } } } | Export-Csv -NoTypeInformation $path\certs.csv