title: Select specific column based on data supplied using Powershell
body: <p>I have a csv file that may have unknown headers, one of the columns will contain email addresses for example.</p>
  
  <p>Is there a way to select only the column that contains the email addresses and save it as a list to a variable?</p>
  
  <p>One csv could have the header say email, another could say emailaddresses, another could say email addresses another file might not even have the word email in the header. As you can see, the headers are different. So I want to be able to detect the correct column first and use that data further in the script. Once the column is identified based on the data it contains, select that column only.</p>
  
  <p>I've tried the where-object and select-string cmdlets. With both, the output is the entire array and not just the data in the column I am wanting.</p>
  
  <pre><code>$CSV = import-csv file.csv
  $CSV | Where {$_ -like "*@domain.com"}
  </code></pre>
  
  <p>This outputs the entire array as all rows will contain this data.    </p>