title: Excel Reading to Powershell Array
body: <p>Dear Stackoverflow(ers),</p>
  
  <p>I have a small problem with powershell and Excel. I have an excel file with several rows and text in them. I would like to read every column and put the content to an array. My script works, but when I show the content of my array there is always one 0 in the beginning. Is there something wrong with my Excel-File or with my Script?</p>
  
  <pre><code>    $a = New-Object -comobject Excel.Application
      $a.Visible = $true
      $a.DisplayAlerts = $False
  
      $Workbook = $a.workbooks.open("C:\test.xls")
      $Sheet = $Workbook.Worksheets.Item("Auto")
  
         $row            = [int]2
         $KN             = @() # beginnt bei 2,1... 3,1... 4,1
         Do {$KN        += $Sheet.Cells.Item($row,1).Text ; $row = $row + [int]1} until (!$Sheet.Cells.Item($row,1).Text)
  
     $Workbook.Close()
     $a.Quit()
     [System.Runtime.Interopservices.Marshal]::ReleaseComObject($a)
  
     Write-Output $KN
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0
  7
  7
  7
  7
  7
  </code></pre>
  
  <p>Excel File looks like that:</p>
  
  <pre><code>A    B    C    D
  7
  7
  7
  7
  7
  7
  </code></pre>
  
  <p>I guess it's some simple error with my array, but I can't find it!
  Thanks!</p>
  
  <p>Edit1:
  The problem lays in the:</p>
  
  <pre><code>  $KN = @()
  </code></pre>
  
  <p>Because if I stop filling the array with my Exceldata, it continues to show me the 0.</p>
  
  <p>Edit2:
  Ok it's getting weird. If I enter $KN, after the Script to look into the content again, it shows the right content without the 0.
  Where does it come from, and why is it there?
  And why is it gone, when I look into the array manually?</p>