I'd like to save a webpage (ASP) exactly as IE would save it as a text file.
I found this and tried:
$ie=New-Object -ComObject InternetExplorer.Application
$ie.Navigate($Page)
$ie.Document.execCommand("SaveAs", $false, "1.txt")
But I'm getting the error:
You cannot call a method on a null-valued expression.
At line:3 char:1
+ $ie.Document.execCommand("SaveAs", $false, "1.txt")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I'm not sure what I'm doing wrong.
If I try to capture the page via
$web = New-Object Net.WebClient
$web | Get-Member
$web.DownloadString($Page) | Out-File "test.html"
I get a page, but it's an error page created by the site letting me know the link is invalid, so it only actually finds the page if I load it through an IE session.
I really just need to automate capturing the IE page as a text file, and I'm hoping to do it without using the SendKey
function. Can anyone assist?