title: How to import CSV column? Import-Csv not working as planned
body: <p>I have a drop down list that's being populated by a CSV file. There are many columns in the CSV, but it only pulls from the <code>Name</code> column. Here's what I have that works just fine in most Win 7, and all Win 8+ PC's I've tried it on.</p>
  
  <pre><code>$customers = Import-CSV "$dir\Apps\customers.csv"
  $List = $customers.name | Sort-Object
  </code></pre>
  
  <p>After that there's a <code>ForEach</code> loop to put each item from the list into the menu.</p>
  
  <p>Lately I've been noticing an issue on a couple Win 7 PC's that I can't figure out. The import option doesn't work unless I specify all the headers with the <code>-Header</code> option. I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/n0S6i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n0S6i.png" alt="enter image description here"></a></p>
  
  <p>After getting it to import correctly by adding all the headers I can't get it to save <code>$customers.name</code> into the <code>$List</code> variable, with or without the sorting. However, if I provide an index number (ex <code>$customers[2].name</code>) it works.</p>
  
  <p>To work around this I've looked at ways to measure the number of rows in the CSV by using the following options after <code>$customers</code>:</p>
  
  <pre><code>$csvlength = Get-Content "$dir\Apps\customers.csv" | Measure-Object - lines
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$csvlength = Import-CSV "$dir\Apps\customers.csv" | Measure-Object
  </code></pre>
  
  <p>From there I can see the length by looking at <code>$csvlength.lines</code> or <code>$csvlength.count</code>.</p>
  
  <p>Is there a way to use that information to save the list of names into <code>$List</code>? I've tried something like this with no success:</p>
  
  <pre><code>$List = $customers[0-$csvlength.count] | Sort-Object
  </code></pre>
  
  <p>Also, I've noticed that when importing the headers it includes <code>Name</code> in the list. If at all possible I'd like to not include the header. I also have a line at the end of the CSV that has other info in it, but no name. That shows up as a blank line. If possible I'd like that to be removed as well.</p>