title: Powershell - how to pass csv fields as parameters
body: <p>I have a problems that I'm trying to solve, but can't seem to figure the key part out. We have tons of records that we process every day using a .jar file, but the problem is that we have to go one by one and that is time consuming. I think we can cut a tremendous amount of time if we use a powershell script. </p>
  
  <p>The problem is that I don't know how to pass the parameters from a csv to a function in powershell. </p>
  
  <p>My csv looks like this </p>
  
  <pre><code>NAME,ID                                                                                                                                                                   
  -------                                                                                                                                                                   
  John,18                                                                                                                                                                     
  Dave,19                                                                                                                                                    
  Carmen,20                                                                                                                                                       
  Eric,21                                                                                                                                                                    
  Tom,22                                                                                                                                                          
  Lisa,23                                                                                                                                                          
  Kyle,24
  </code></pre>
  
  <p>The function is</p>
  
  <pre><code>function CreateUser 
  &amp; java -jar --create -user $name -id $id -file D:/HR/$name-$id-form.pdf
  </code></pre>
  
  <p>I imported the csv file using</p>
  
  <pre><code>$dataCSV = "D:\HR\Input\20150303NewUsers.csv"
  $data = Import-Csv $dataCSV
  </code></pre>
  
  <p>So I need something that will go systematically down the file and pass the name field inside the csv as $name and the ID field as $id over and over again until completed. But I can't figure out how to pass those two down on a ForEach-Object method :( </p>
  
  <p>I'm stuck... I've been fighting this all weekend, but nothing. </p>
  
  <p>Any help or guidance will be greatly appreciated! Or if anyone know how to do this in python, that will be cool too! :) </p>