title: Read Excel File with Powershell
body: <p>I've got a excel serverlist where column D is hostnames and column F area (like dev, int, prd). Now I want to read this excelfile with powershell and printout each hostname that has the area dev. What do I have to change? </p>
  
  <pre class="lang-powershell prettyprint-override"><code>$FilePath = "C:\serverlist.xlsx"
  $SheetName = "serverlist"
  $objExcel = New-Object -ComObject Excel.Application
  $objExcel.Visible = $false
  $WorkBook = $objExcel.Workbooks.Open($FilePath)
  $WorkSheet = $WorkBook.sheets.item($SheetName)
  
  
  $Range = $WorkSheet.Range("F2:F150").Text
  
  Foreach ($cell in $Range) {
  
      If ($cell -like "dev") {
  
          Write-Host "hostname from  Column D"
  
      }
  
  }
  </code></pre>