title: Select CSV columns in Powershell where header name contains a specific string
body: <p>I have a data file of about 10-15 columns from which I want to extract specific columns. Some of the columns I know the exact column header and others I only know that the first two letters will always be "FC".
  How do I select only the columns where I know the column header and those that start with "FC"?
  Starting with just the "FC" columns, I have tried like this:</p>
  
  <pre><code>$myCSV = Import-CSV "mydata.txt" -Delimiter "`t"
  $FCcols = $myCSV[0].psobject.Properties | foreach { $_.Name } | Where {$_ -match "FC"}
  $myCSV | select $FCcols
  </code></pre>
  
  <p>But I just get an error:</p>
  
  <pre><code>Select-Object : Cannot convert System.Management.Automation.PSObject to one of 
  the following types {System.String, System.Management.Automation.ScriptBlock}.
  At line:3 char:16
  + $myCSV | select &lt;&lt;&lt;&lt;  $FCcols
      + CategoryInfo          : InvalidArgument: (:) [Select-Object], NotSupport 
     edException
      + FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Co 
     mmands.SelectObjectCommand
  </code></pre>
  
  <p>Then, if I try:</p>
  
  <pre><code>$myCSV = Import-CSV "mydata.txt" -Delimiter "`t"
  $FCcols = [System.Collections.ArrayList]@()
  $myCSV[0].psobject.Properties | foreach { $_.Name } | Where {$_ -match "FC"} | %{$FCcols.Add($_)}
  $myCSV | select $FCcols
  </code></pre>
  
  <p>I get the output I want except that it is in "column header : value" format, like this:</p>
  
  <pre><code>FC1839 : 0
  FC1842 : 1
  FC1843 : 6
  FC1844 : 12
  FC1845 : 4
  
  FC1839 : 0
  FC1842 : 0
  FC1843 : 19
  FC1844 : 22
  FC1845 : 14
  </code></pre>
  
  <p>I am probably just missing something simple, but how do I get to the point that I am able to select these matching columns and then output them to another .txt file (without the header : value format)?</p>