Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Replacing csv header row

$
0
0

I typically build a custom psobject and fill it with the desired property names and values before exporting to CSV. Don't know if it's applicable in your specific case though.

$result = foreach($item in $dataSource) {
    Write-Output (New-Object psobject -Property @{
        FirstName = $item.givenName
        LastName = $item.surName
        # And so on..
    })
}
 
Export-Csv -InputObject $result -Path 'C:\CSV\result.csv' -NoTypeInformation

Viewing all articles
Browse latest Browse all 13067

Trending Articles