title: Powershell Web Page Automation works on Internet, not Intranet
body: <p>I'm trying to do some simple automation with Powershell, pulling link URLs from one of our company's local intranet pages, and then doing some work with those URLs. Eventually I'll use the script to open each link and click a button on the page. I'm using Internet Explorer 9 in Windows 7 x64.</p>
  
  <p>Here's an example of a simple working powershell script that displays all the links on a page:</p>
  
  <pre><code>$ie = new-object -com "InternetExplorer.Application"
  $ie.Visible = $true
  $ie.Navigate( "http://www.reddit.com" )
  While ($ie.Busy) {
      Sleep 1
  }
  
  $links = $ie.Document.getElementsByTagName("a")
  $links | foreach {
      write-host $_.href
  }
  </code></pre>
  
  <p>This script works fine until I replace the URL with a local intranet site. It follows the normal URL scheme ( <a href="http://internaldomain.com/etc" rel="nofollow">http://internaldomain.com/etc</a> ), but it's recognized as an intranet site. Once I'm trying to scrape a page in the intranet zone, the $ie.Document value suddenly becomes NULL and the script fails.</p>
  
  <p>I'm guessing it's related to some obscure setting for that zone... I'm not sure. I found some suggestions online such as adding it to your trusted sites, but that has not worked. This is my first time using Powershell for web automation, so any help or insight would be appreciated.</p>