我一直试图解决这个问题一段时间,但似乎无法找到一个体面的解决方案。我在 Powershell 脚本中提取两个 certutil 命令的输出:
certutil -View -config $CAserver -restrict "Disposition=20" csv >> $output1
certutil -View -config $CAserver -restrict "Disposition=16" csv >> $output2
问题是我正在单独获取每个处置的标题,即使将其作为“处置> = 16,处置< = 20”的单行进行,并且它会进一步破坏事情。我正在寻找一种从一个命令中获取值并将其附加到另一个命令的 csv 的方法。
电流输出:
"HeaderA1","HeaderA2","HeaderA3","HeaderA4"
"ValueA1","ValueA2","ValueA3","ValueA4"
"HeaderB1","HeaderB2","HeaderB3","HeaderB4"
"ValueB1","ValueB2","ValueB3","ValueB4"
期望的输出:
"HeaderA1","HeaderA2","HeaderA3","HeaderA4"
"ValueA1","ValueA2","ValueA3","ValueA4"
"ValueB1","ValueB2","ValueB3","ValueB4"
解释输出的示例代码:
$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'