title: Powershell script returns only first value in Excel range
body: <p>I'm getting some errors while trying to read Excel spreadsheet. I'm trying to read values in cells <code>B2</code> to <code>B15</code>, but am only getting back <code>B2</code>.</p>
  
  <p>Can someone help fix my code, so that all the correct lines can be written as output? Please and thanks...</p>
  
  <p><strong>Excel Table</strong></p>
  
  <p>a-n</p>
  
  <p><strong>PowerShell Code</strong></p>
  
  <pre><code>$objExcel = New-Object -ComObject Excel.Application
  $workbook = $objExcel.Workbooks.Open("C:\administrator\Book1.xlsx")
  $sheet = $workbook.Worksheets.Item("Sheet1")
  $rowMax = ($sheet.UsedRange.Rows).count
  
  $i = 2;
  $data = $sheet.Cells.Item($i,2).text 
  $get = @{"$data"="value"}
  
  foreach ($Key in ($get.GetEnumerator()))  {
      $i++;
      $Key.name
  }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <p>I just get the first line of output, <code>a</code>, rather than the expected 14 lines from row 2-15, with the output being <code>a-n</code>.</p>