powershellcsvexport-csv

Powershell export-csv with no headers?


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?


Solution

  • 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"