Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output a CSV using PowerShell without the "#TYPE" line?

Tags:

powershell

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:

#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?

like image 338
kickinchicken Avatar asked May 14 '13 16:05

kickinchicken


People also ask

How do I Export PowerShell output to CSV?

To do this we can use the Export-CSV function in PowerShell. The Export-CSV function converts PowerShell objects into a CSV string and saves them into a CSV file. If you only need a CSV string, then you can also use the ConvertTo-CSV function in PowerShell.

How do I output a CSV file?

Go to File > Save As. Click Browse. In the Save As dialog box, under Save as type box, choose the text file format for the worksheet; for example, click Text (Tab delimited) or CSV (Comma delimited).

What does :: mean in PowerShell?

Static member operator :: To find the static properties and methods of an object, use the Static parameter of the Get-Member cmdlet. The member name may be an expression. PowerShell Copy.


1 Answers

Add the NoTypeInformation switch, like this:

Export-Csv "../SSIS/Import Data/ADUsers.csv" -NoTypeInformation 
like image 118
Frode F. Avatar answered Sep 25 '22 12:09

Frode F.