Using internet explorer in a power shell

Hello,

I have to open a multitab internet explorer from a power shell script. After I would like to save the content on a file. My problem is coming from Javascript. The content I have to save is rendered through javascript. How can I let run Javascript and then save the content?

 

Best regards.

Jean.

 

Nothing was shared on what you accomplished or the ‘content’ you want. The ie com object can be used to emulate button clicks, scrolling or any interaction with website:

https://westerndevs.com/simple-powershell-automation-browser-based-tasks/

As you can see in the above, you can also use DOM to parse the page and get content.

I have done what you seem to be asking. Here is my $.02.

In my case, I was creating a digital signature via the Canvas element and saving that image/signature to a file. The HTML page was created from a PowerShell script and then opened in IE. The reason I chose to open in IE is that IE/EDGE are the only browsers that seem to honor your admin privileges on the system in that if you want to save the file to a restricted folder (limited to admins only which was my case), only IE/EDGE would honor those permissions. Chrome/FF did NOT.

For saving an image file, look into javascript/toDataURL to get that done. That is how I accomplished the task. Since I did this with JavaScript, and mine is specific to saving an image from canvas, I dont feel it appropriate to post the code here. You should be able to find many examples in a google search.

Not sure exactly what you want to save but if you want to save HTML content, it looks like you need to use the Blob object.

https://stackoverflow.com/questions/27177661/save-html-locally-with-javascript

As for building your HTML from PowerShell, can you show what you have tried? In my case, I built the page with what I call brute force and then added table content using PowerShell ConvertToHTML.