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:
I was able to successfully convert this into Powershell code that works on v2.
The main problem is that when you run this code on any computer;
"Windows Security Warning
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
It's a bit tricky, as those COM objects are just using Internet Explorer (and not in a way that is really safe for scripting, as you've found; they will pop up GUI elements from time to time.)
If you don't mind distributing a DLL in order to make your script work, I'm a big fan of the HTML Agility Pack for this sort of thing: https://htmlagilitypack.codeplex.com/ . Check out http://www.leeholmes.com/blog/2010/03/05/html-agility-pack-rocks-your-screen-scraping-world/ for a nice blog / example of using this from PowerShell.
Thank you for your reply Dave. I am looking to avoid any 3rd party tools if at all possible. Would .net tools like cookiecontainers be a better option? Or do you know if the invoke-webrequest code is posted somewhere?
You must be logged in to reply to this topic.