I was able to do this with Powershell v3 however I discovered that the large majority of computers in the environment I work in are running Powershell v2 which puts a huge kink in what I am trying to accomplish.
Goal: To remotely execute a powershell command that will return (not the code) but the resulting web content generated by executing the code in the default browser of that remote computer.
Powershell v3 code:
$webresponse = Invoke-WebRequest -Uri $url
$response = $webresponse.allelements[0].innertext
I was able to successfully convert this into Powershell code that works on v2.
Powershell v2:
$ParsedHTML = New-Object -com “HTMLFILE”
$webresponse = (New-Object System.Net.WebClient).DownloadString($url)
$ParsedHTML.IHTMLDocument2_write($webresponse)
$response = $ParsedHTML.Body.InnerText
The main problem is that when you run this code on any computer;
$ParsedHTML.IHTMLDocument2_write($webresponse)
it prompts the user with a yes or no response to the following popup.
“Windows Security Warning
To allow this website to provide information personalized for you, will you allow it to put a small file (called a cookie) on your computer?”
I am attempting to find a method to auto accept this prompt, to allow my script to work but more over the website that I am going to is checking to see if cookies are enabled and by clicking yes or no it changes that resulting output.
Note: If you are interested in trying it out yourself
$url = “http://www.respondus.com/browser/ie.pl”