Have successfully using Powershell to access IE. Trick to be aware of.
If you launch a web page using "New-Object -comObject InternetExplorer.Application", UAC will block you from accessing the document properties inside. Use the following technique:
& "$env:programfiles\Internet Explorer\iexplore.exe" 'http://powershell.com'
$win = New-Object -comObject Shell.Application
$try = 0
$ie2 = $null
do {
Start-Sleep -milliseconds 500
$ie2 = @($win.windows() ? { $_.locationName -like '*PowerShell*' })[0]
$try ++
if ($try -gt 20) {
Throw "Web Page cannot be opened."
}
} while ($ie2 -eq $null)
$ie2.document
$ie2.Document.body.innerHTML
If you launch a web page using "New-Object -comObject InternetExplorer.Application", UAC will block you from accessing the document properties inside. Use the following technique:
& "$env:programfiles\Internet Explorer\iexplore.exe" 'http://powershell.com'
$win = New-Object -comObject Shell.Application
$try = 0
$ie2 = $null
do {
Start-Sleep -milliseconds 500
$ie2 = @($win.windows() ? { $_.locationName -like '*PowerShell*' })[0]
$try ++
if ($try -gt 20) {
Throw "Web Page cannot be opened."
}
} while ($ie2 -eq $null)
$ie2.document
$ie2.Document.body.innerHTML
Comments
Post a Comment