title: PowerShell IE9 ComObject has all null properties after navigating to webpage
body: <p>I have a PowerShell script that navigates to a (presumably) classic ASP page on our intranet to stop a Windows Service running on our server as part of the deployment process for that service (and restarts it after deploying the new files). It ran fine until we recently upgraded to IE9. Here's the script.</p>
  
  <pre><code># Open service page in IE
  $ie = new-object -comobject InternetExplorer.Application
  $ie.visible = $true
  $ie.navigate($serviceUrl)
  while($ie.busy) { start-sleep 1 }
  
  # Stop service
  $ie.Document.getElementById("dropDownActionList").value = "Stop"
  $ie.Document.getElementById("buttonTakeAction").click()
  while($ie.busy) { start-sleep 1 }
  </code></pre>
  
  <p>Now when I run the script, it successfully launches IE, but throws the following error:</p>
  
  <pre><code>You cannot call a method on a null-valued expression.
  At C:\Projects\ABC\Scripts\Deploy.ps1:85 char:28
  + $ie.Document.getElementById &lt;&lt;&lt;&lt; ("dropDownActionList").value = "Stop"
      + CategoryInfo          : InvalidOperation: (getElementById:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>When I investigate in PowerShell, I find that if I create the IE ComObject, it at first has valid properties, but as soon as I navigate to the the service control page, all the properties are null (almost as if the ComObject gone away?). For example, before the <code>HWND</code> property had a valid value, but now it's null (<code>$ie.hwnd -eq $null</code> returns true). No error is displayed in PowerShell when I navigate to the page.</p>
  
  <p>I looked at some <a href="https://stackoverflow.com/questions/12733143/powershell-system-comobject-document-property-no-longer-works-under-ie-9">similar</a> <a href="https://stackoverflow.com/questions/6065359/powershell-ie9-and-getelementbyid">questions</a>, but the first one doesn't match my circumstance (the <code>Document</code> property is null in my case) and as for the latter one, IE9 defaults to compatibility mode for intranet sites. I saved the ASP page and ran it through the <a href="http://validator.w3.org/" rel="nofollow noreferrer">w3c validator</a> and it threw some errors (although none related to the elements I'm trying to deal with). Unfortunately I can't fix those. Other sites don't seem to have this problem. Any suspicions on what the problem may be and recommendations on work-arounds?</p>