0

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'
3
  • Welcome to SO. Can you show us the contents of $output1 and $output2 produced by your certutil calls; some PowerShell code you've tried parsing $output1 and $output2; and also the expected output result? Commented Jul 1, 2020 at 13:17
  • I'll add it to my question Commented Jul 1, 2020 at 13:28
  • cmdlets are powershell commands written in c#. You can skip the first line of output in the second command. Commented Jul 1, 2020 at 14:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.