I've been trying to solve this problem for a while but can't seem to find a decent solution. I'm pulling the output of two certutil commands inside of a Powershell script:
certutil -View -config $CAserver -restrict "Disposition=20" csv >> $output1
certutil -View -config $CAserver -restrict "Disposition=16" csv >> $output2
Problem is that I'm getting the headers for each disposition individually even if do this as a one-liner with "Disposition>=16,Disposition<=20" and it's breaking things further down the line. I'm looking for a way to take the values from one command and append it to the csv of the other.
Current output:
"HeaderA1","HeaderA2","HeaderA3","HeaderA4"
"ValueA1","ValueA2","ValueA3","ValueA4"
"HeaderB1","HeaderB2","HeaderB3","HeaderB4"
"ValueB1","ValueB2","ValueB3","ValueB4"
Desired output:
"HeaderA1","HeaderA2","HeaderA3","HeaderA4"
"ValueA1","ValueA2","ValueA3","ValueA4"
"ValueB1","ValueB2","ValueB3","ValueB4"
Example code to interpret the outputs:
$import = Import-Csv $output | Where-Object { ($_. "Certificate Template" -eq <TEMPLATE_STRING>) -OR ($_. "Request Disposition" -match <DISPOSITION_STRING>) } | Select-Object 'Issued Common Name','Certificate Effective Date','Certificate Expiration Date','Certificate Template','Serial Number'