ty

🧩 Syntax:
function Get-IssuedCertificates {

    # Connecting to the Certificate Authority 
     $objCertView = New-Object -ComObject CertificateAuthority.View
     $objCertView.OpenConnection("ADCS\ADCS-ADCS-CA")
 
     # Get a column count and place columns into the view 
     $iColumnCount = $objCertView.GetColumnCount(0)
     $objCertView.SetResultColumnCount($iColumnCount)
 
     # Place each column in the view
     for ($x=0; $x -lt $iColumnCount; $x++)
     {
        $objCertView.SetResultColumn($x)
     } 
 
     # Open the View and reset the row position 
     $objCertViewRow = $objCertView.OpenView(); 
     $objCertViewRow.Reset(); 

     $certReqs = @()
     for ($x = 0; $objCertViewRow.Next() -ne -1; $x++) 
     { 
        # Columns with the info we need
        $certReq = @{} 
        $objCertViewColumn = $objCertViewRow.EnumCertViewColumn() 
        while ($objCertViewColumn.Next() -ne -1) 
        {
            $certReq[$objCertViewColumn.GetName()] = $objCertViewColumn.GetValue(0)
        }
       $certReqs += [PSCustomObject]$certReq
        
     }
     return $certReqs
 }

$certs = Get-IssuedCertificates
$certs | Export-Csv -NoTypeInformation -Path test2.csv