title: ForEach Property in Get-Member
body: <p>I have the following snippet of code in my powershell script</p>
  
  <pre><code>    $sqlHDR = "SELECT * FROM OPENROWSET ('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=" + $dir + $m + ".xls;HDR=NO','SELECT * FROM [" + $y + "`$B1:Z1]')"
      $doHDR = invoke-sqlcmd -query $sqlHDR -ServerInstance $sqlserver -Database $db
  
      $doHDR | get-member -membertype properties
  </code></pre>
  
  <p>This is part of a loop that cycles through hundreds of Excel spreadsheets.  The result is a dynamically changing set of columns from F1 through to F*n* (<em>n</em> being the unknown final column number) which have only one row, with a single value in each row.</p>
  
  <p>I wondered if I could use get-member to somehow loop through the columns in the dataset to gain access to the values in field?  Or am I going about this completely backwards, is there a better way to loop through the values in a single datarow?</p>
  
  <p>Alternatively is there a way to loop through the property names themselves?</p>
  
  <p>Many thanks!</p>