简体   繁体   English

Powershell CSV导出-更改列

[英]Powershell CSV Export - Change columns

I want the different results of the patterns in different rows but exactly in that order. 我希望在不同的行中按不同的顺序获得不同的模式结果。 My Problem is, it's all in 1 column. 我的问题是,全都在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

Example: 例:

It's currently this: 当前是这样的:

在此处输入图片说明

I want it like this: 我想要这样: 在此处输入图片说明

But I have no idea what to do 但是我不知道该怎么办

Thanks in advance. 提前致谢。

Cheers 干杯

Try declaring $content as a collection before putting stuff in it. 尝试在将内容放入其中之前将$ content声明为一个集合。

$content = @()

then just | 然后 it to out-csv; 将其输出到cv; no need to select-object -property line 无需选择对象属性行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM