【问题标题】:Powershell Format-Table to CSVPowershell 格式表转 CSV
【发布时间】:2014-06-19 11:58:08
【问题描述】:

我在 Powershell 中有以下行来输出数据数组。我遇到的问题是 Name,Title,Department 没有进入列。取而代之的是,我在单个单元格中的每一行中得到一列,中间有标签。

$outList | Format-Table Name,Title,Department -auto >c:\Scripts\test2.csv

如何输出到列中?

【问题讨论】:

    标签: powershell csv formatting


    【解决方案1】:

    您应该改用 Export-Csv cmdlet。

    $outList | Export-Csv -path c:\scripts\test.csv -NoTypeInformation
    

    如果您只需要选定的字段,请先将其通过管道传输到 Select-Object cmdlet。

    $outList | Select-Object -Property Name, Title, Department | Export-Csv -path c:\scripts\test.csv -NoTypeInformation
    

    【讨论】:

      猜你喜欢
      • 2020-12-05
      • 2022-11-18
      • 2021-05-16
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多