Export to .csv remove header and

I am trying to script an export from AD to a separate DB to run daily. I need to remove the header and some other gibberish so

I can import into the DB cleanly, is there a way to do this? The first 2 lines shown below I need to try to get rid of.

#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser
givenname surname department emailaddress office
Here is my code:

Get-ADUser -Filter {department -like “*”} -Properties givenname, surname, department, emailaddress, office |Select-Object givenname, surname, department, emailaddress, office |Export-Csv “c:\emailaddress.csv”

 

 

Each reasonable tool able to import standards-compliant CSV files should be able to deal with this information. Nevertheless you can easily avoid to have one of them by using the parameter -NoTypeInformation. I reccommend that you carefully read the help for the cmdlets you use, including the examples, to learn how to use them.
To remove the headers from a csv file usually does not make any sense.
BTW: When you post code plaease format it as code. Thanks

If you need to remove the header row you’ll need to do a little extra work. As Olaf mentioned, the -NoTypeInformation will get rid of the metadata.

For the header row itself, you need to use a slightly different cmdlet to let you trim the file before export:

https://gist.github.com/vexx32/04765a62977dc2ef9316aa43f49fb3d3

Sorry, I did see that in the “Read before you post” Thanks for the help Olaf and Joel, much appreciated