Powershell CSV导出-更改列

时间:2018-09-07 14:12:32

标签: powershell

我希望模式在不同行中的结果不同,但顺序要正确。我的问题是,全都在1列中。

$path = ".\WSUS_Report.txt"

$pattern_rubrik = '(?<=Kind).+?($)'
$pattern_result = '(?<=Result).+?(?=\.)'
$pattern_sysname = '(?<=System).+?($)'

$content = Select-String -Path $Path -Pattern $pattern_sysname,$pattern_rubrik,$pattern_result -AllMatches

$content | Out-GridView
$content | Select-Object -Property Line  |  Export-Csv Report.csv -NoTypeInformation

示例:

目前是这样:

enter image description here

我想要这样: enter image description here

但是我不知道该怎么办

谢谢。

欢呼

1 个答案:

答案 0 :(得分:0)

在将内容放入其中之前,尝试将$ content声明为一个集合。

$content = @()

然后只是|将其输出到cv;无需选择对象属性行

相关问题