简体   繁体   English

如何在没有“#TYPE”行的情况下使用PowerShell输出CSV?

[英]How do I output a CSV using PowerShell without the “#TYPE” line?

this is sort of related to another post. 这与另一篇文章有​​关。 I've got the following script written: 我写了以下脚本:

Get-ADUser -Filter * -SearchBase 'DC=aaaa,DC=com' | Export-CSV "ADUsers.csv"

This outputs a CSV file but at the first row of the file reads: 这会输出一个CSV文件,但在文件的第一行显示:

#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser"

This is messing up SSIS when it tries to read it. 当它试图读取它时,这会弄乱SSIS。 Is there any way of not adding that first line? 有没有办法不添加第一行?

添加NoTypeInformation开关,如下所示:

Export-Csv "../SSIS/Import Data/ADUsers.csv" -NoTypeInformation

您还可以使用:

Export-Csv "../SSIS/Import Data/ADUsers.csv" -NoType

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

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