title: How can I store data from a CSV file into local variables for a Powershell script?
body: <p>I'm trying to read a csv file and store its data into variables that I will use for Powershell scripts. 
  I managed to read the file by doing the following command:</p>
  
  <pre><code>$csv = Import-Csv C:\Users\[...]\Documents\ipaddresses.csv -delimiter "|" 
  $csv
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <pre><code>IP          Name
  --          ----
  165.XX.XX.1 n1
  165.XX.XX.2 n2
  165.XX.XX.3 n3
  165.XX.XX.4 n4
  165.XX.XX.5 n5
  165.XX.XX.6 n6
  </code></pre>
  
  <p>The idea is that I could create 6 variables each like: </p>
  
  <pre><code>$Name = $IP
  </code></pre>
  
  <p>However, when I try to loop the objects of the $csv variable and store them into arrays like this:</p>
  
  <pre><code>foreach($item in $csv){
      IP = $($item.IP) 
      Name = $($item.Name)
  }
  </code></pre>
  
  <p>It returns me empty arrays. How do I fix this? </p>