title: Read Excel sheet in Powershell
body: <p>The below script reads the sheet names of an Excel document....</p>
  
  <p>How could I improve it so it could extract all the contents of column B (starting from row 5 - so row 1-4 are ignored) in each worksheet and create an object?</p>
  
  <p>E.g. if column B in worksheet 1 (called London) has the following values:</p>
  
  <pre><code>Marleybone
  Paddington
  Victoria
  Hammersmith
  </code></pre>
  
  <p>and column C in worksheet 2 (called) Nottingham has the following values:</p>
  
  <pre><code>Alverton 
  Annesley
  Arnold
  Askham
  </code></pre>
  
  <p>I'd want to create a object that from that looks like this:</p>
  
  <pre><code>City,Area
  London,Marleybone
  London,Paddington
  London,Victoria
  London,Hammersmith
  Nottingham,Alverton 
  Nottingham,Annesley
  Nottingham,Arnold
  Nottingham,Askham
  </code></pre>
  
  <p>This is my code so far:</p>
  
  <pre><code>clear all
  
  sheetname = @()
  
      $excel=new-object -com excel.application
      $wb=$excel.workbooks.open("c:\users\administrator\my_test.xls")
      for ($i=1; $i -le $wb.sheets.count; $i++)
      {
        $sheetname+=$wb.Sheets.Item($i).Name;
      }
  
  $sheetname
  </code></pre>