Powershell export-csv with no headers?

Shaun Z. picture Shaun Z. · Oct 15, 2014 · Viewed 59.8k times · Source

So I'm trying to export a list of resources without the headers. Basically I need to omit line 1, "Name".

Here is my current code:

Get-Mailbox -RecipientTypeDetails RoomMailbox,EquipmentMailbox | Select-Object Name | Export-Csv -Path "$(get-date -f MM-dd-yyyy)_Resources.csv" -NoTypeInformation

I've looked at several examples and things to try, but haven't quite gotten anything to work that still only lists the resource names.

Any suggestions? Thanks in advance!

Answer

mjolinor picture mjolinor · Oct 15, 2014

It sounds like you basically want just text a file list of the names:

Get-Mailbox -RecipientTypeDetails RoomMailbox,EquipmentMailbox |
 Select-Object -ExpandProperty Name | 
 Set-Content -Path "$(get-date -f MM-dd-yyyy)_Resources.txt"

Edit: if you really want an export-csv without a header row:

(Get-Mailbox -RecipientTypeDetails RoomMailbox,EquipmentMailbox |
Select-Object Name |
ConvertTo-Csv -NoTypeInformation) |
Select-Object -Skip 1 |
Set-Content -Path "$(get-date -f MM-dd-yyyy)_Resources.csv"