Powershell 格式表转 CSV

标签 powershell csv formatting

我在 Powershell 中有以下行来输出数据数组。我遇到的问题是 Name、Title、Department 没有进入列。相反,我在单个单元格中的每一行中得到一列,中间有制表符。

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

如何输出到列中?

最佳答案

您应该改用 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

关于Powershell 格式表转 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23434251/

相关文章:

java - List<String> 的列表到字符串有序的字符串数组

vb.net - 如何找到excel.exe路径和notepad.exe路径

linux - 使用 awk 清理 csv 文件的标题

用于格式化(或美化)html、xml、.java 文件的 Java API 或 Web 服务

java - Eclipse (ctrl+shift+f) 什么都不做

powershell - 换行符在 powershell 中不起作用,同时替换

powershell - 使用 powershell 将数据发布到 Elastic Search 的最佳方式是什么?

powershell - Powershell别名的多个值

ruby-on-rails - 将日期解析为 Rails 友好的格式

c++ - 通过 Powershell 远程 session 执行时程序输出不同