Powershell Web Page Automation works on Internet, not Intranet -
i'm trying simple automation powershell, pulling link urls 1 of our company's local intranet pages, , doing work urls. i'll use script open each link , click button on page. i'm using internet explorer 9 in windows 7 x64.
here's example of simple working powershell script displays links on page:
$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 }
this script works fine until replace url local intranet site. follows normal url scheme ( http://internaldomain.com/etc ), it's recognized intranet site. once i'm trying scrape page in intranet zone, $ie.document value becomes null , script fails.
i'm guessing it's related obscure setting zone... i'm not sure. found suggestions online such adding trusted sites, has not worked. first time using powershell web automation, or insight appreciated.
maybe solution here: http://blogs.msdn.com/b/ieinternals/archive/2011/08/03/internet-explorer-automation-protected-mode-lcie-default-integrity-level-medium.aspx
it explained different levels of tabs, in ie. have use "medium tab" navigate in local zone.
basically, best way keep ie settings , use script create registry key, explained in link above.
windows registry editor version 5.00 [hkey_classes_root\internetexplorer.applicationmedium] [hkey_classes_root\internetexplorer.applicationmedium\clsid] @="{d5e8041d-920f-45e9-b8fb-b1deb82c6e5e}"
and in script, use new com object:
$ie = new-object -com internetexplorer.applicationmedium ...
Comments
Post a Comment