# Export to .csv remove header and

**URL:** <https://forums.powershell.org/t/export-to-csv-remove-header-and/11605>\
**Category:** PowerShell Help\
**Created:** [November 2, 2018, 9:06am UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605 "2018-11-02T09:06:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [November 2, 2018, 9:06am UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605/1 "2018-11-02T09:06:58Z")

</div>

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”

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 2, 2018, 9:22am UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605/2 "2018-11-02T09:22:02Z")

</div>

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](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-5.1), 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

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [November 2, 2018, 9:36am UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605/3 "2018-11-02T09:36:45Z")

</div>

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>

---

<div class="post-metadata">

**Author:** ![uinthas](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uinthas](https://forums.powershell.org/u/uinthas)\
**Post date:** [November 2, 2018, 9:49am UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605/4 "2018-11-02T09:49:20Z")

</div>

> [@](#):
>
> BTW: When you post code plaease format it as code. Thanks

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/export-to-csv-remove-header-and/11605/5 "2024-05-16T20:33:45Z")

</div>

Closed on May 16, 2024, 8:33pm UTC


