Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - ConvertFrom-CSV not taking headers

$
0
0

Hi guys,

I'm just testing a REST API for our Redmine system and hoping to use powershell to script some events.

My script so far:

remove-variable result

$url = "http://address:3000/redmine/issues.csv?key=b8dedadf7bf2554b63652XXXXXXXXX7affd2a"
$result = Invoke-RestMethod -uri $url -Method Get
$csv = $result | ConvertFrom-Csv
$csv

The REST call returns a string formatted to CSV correctly, an example:

#,Project,Tracker,Status,Priority,Subject,Assignee,Updated,Due date,% Done
1452,NOC Redmine project,Task,New,Normal,Test task relationships,Name,03/07/2013 09:54 am,06/07/2013,20
1451,NOC Redmine project,Query,New,Normal,Differentiate main task in GANTT,Name,03/07/2013 09:43 am,06/07/2013,0
1450,NOC Redmine project,Query,New,Normal,Add notification for users when added to an installation,Name,03/07/2013 09:43 am,06/07/2013,0
1449,NOC Redmine project,Task,New,Normal,Upgrade Redmine,Name,03/07/2013 08:15 am,"",0
1447,NCR Management System,Incident,Feedback,Normal,Wrong Stock Received,Name,02/07/2013 10:38 am,"",100
1445,NCR Management System,Incident,New,Normal,Incorrect Quantity Sent,Name,02/07/2013 10:38 am,"",100

So this is all well and good,  I was expecting to use the ConvertFrom-CSV  cmdlet to convert it into objects etc. In a way this is working, except it disregards the top line as headers.

Which takes the second line as headers and results in this:

1452                    : 58
NOC Redmine project     : Redmap e-document management
Task                    : Task
New                     : New
Normal                  : High
Test task relationships : Proof of concept
Name                    : 
03/07/2013 09:54 am     : 21/11/2012 11:16 am
06/07/2013              : 
20                      : 70

I just cant figure out why it is disregarding the first line?



Viewing all articles
Browse latest Browse all 15028

Trending Articles