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

时间:2022-02-09 00:34:41

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. Is there any way of not adding that first line?

当它试图读取时,这会弄乱SSIS。有没有办法不添加第一行?

2 个解决方案

#1


30  

Add the NoTypeInformation switch, like this:

添加NoTypeInformation开关,如下所示:

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

#2


1  

You can also use:

您还可以使用:

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

#1


30  

Add the NoTypeInformation switch, like this:

添加NoTypeInformation开关,如下所示:

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

#2


1  

You can also use:

您还可以使用:

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