title: Get powershell to control Internet Explorer and switch between 2 webpages
body: <p>I want to have Internet Explorer to switch between 2 different webpages in an endless loop . The webpages is local files, that has to be viewed for 10 seconds before changing to next webpage. My code so far:</p>
  
  <pre><code>$ie = New-Object -Comobject 'InternetExplorer.Application'
  $ie.Visible = $true
  
  function IEWeb {
      $ie.navigate(file://D:\web\index.html)
      Start-sleep 10
      $ie.navigate(file://D:\web\index2.html)
      Start-sleep 10
  }
  
  while($true) {
      IEWeb
  }
  </code></pre>
  
  <p>Everything is working until the second webpage has to be loaded.
  Then I get an error message:</p>
  
  <blockquote>
    <p>Object is disconnected from it's clients. (Exception from HRESULT:0x800010108 (RPC_E_DISCONNECTED))</p>
  </blockquote>
  
  <p>I have tried with global vars but still the same.
  Can anyone give Me a hint of what I'm missing?</p>