title: PowerShell - Loop through divs on webpage and print their ID
body: <p>I'm using PowerShell to navigate to a webpage.  I'm looping through all the divs:</p>
  
  <pre><code>$ie = New-Object -com InternetExplorer.Application 
  
  $ie.visible=$true
  
  $ie.navigate("URL")   
  
  $divs = $ie.document.getElementsByTagName("div")
  Foreach($div in $divs)
  {
      $div
  }
  </code></pre>
  
  <p>This identifies the divs as being "System.__ComObjects".  Get-Member returns methods like "ie9_getAttribute" which sound promising (though I'm using IE11...) but "<strong>$div.ie9_getAttribute("id")</strong>" throws:</p>
  
  <pre><code>Exception calling "ie9_getAttribute" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
  </code></pre>
  
  <p>for the first div and:</p>
  
  <pre><code>Method invocation failed because [System.__ComObject] doesn't contain a method named 'ie9_getAttribute'.
  </code></pre>
  
  <p>for subsequent divs.</p>
  
  <p><a href="http://pastebin.com/KRLv81v6" rel="nofollow">Here is the HTML I am parsing.</a></p>
  
  <p>How can I extract an ID from a "System.__ComObject"? </p>