ConvertFrom-CSV converts the property names as values when using the Header parameter - by Arnaud Petitjean

Status : 

 


1
0
Sign in
to vote
ID 777627 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 1/27/2013 10:42:17 AM
Access Restriction Public

Description

When using ConvertFrom-CSV with -Header to remap the property names, ConvertFrom-CSV generates a list of values including the property names.

Example 1: works as expected 

PS > whoami.exe /user /FO CSV | ConvertFrom-Csv 

User Name                SID
---------                ---
arnaud-mac-pc\arnaud-mac S-1-5-21-2729936480-2636444230-3151370031-1000

Example 2: does not work as expected 

PS > whoami.exe /user /FO CSV | ConvertFrom-Csv -Header @('Name','SecurityID')

Name                     SecurityID
----                     ----------
User Name                SID
arnaud-mac-pc\arnaud-mac S-1-5-21-2729936480-2636444230-3151370031-1000

I know it's written in the doc to omit the header in the CSV string, but it should work as Export-CSV. Export-CSV ignores the header when using the Header parameter. I would expect the same behaviour.

Sign in to post a comment.