Using PowerShell with Internet Explorer

PowerShell is a great language, I am often amazed at how far it can actually reach and what you can gather data, write data or use data from.

Mainly I use PowerShell to manage my VMware environment but last night I broke from my comfort zone and took some time to see what I was able to do with Internet Explorer – Did you know you can programmatically browse the web with PowerShell ?  Well you can!

The Reason

First thing I needed was a reason, at the moment there is a poll for top virtualization blogs, last year I surprisingly did very well in this and would like to thank anyone who voted for me.  This year as I was filling it out and selecting some of my favorite blogs from the list.  People like Duncan Epping, Eric Sloof, William Lam, Luc Dekens, Jonathan Medd, Frank Denneman the list goes on and on and then I found my blog tucked away near the bottom amongst the other blogs beginning with V… as this is a virtualization top list you can imagine there were a few beginning with V!

Anyway, I thought there must be an easier way to allow people to vote for me than to hope they find me amongst the V’s and don’t get bored along the way and choose others so here it is:

The below script is not a cheating script, it will not make you vote for me 1000 times it will simply start internet explorer, browse to the survey and select my site for you, one this has done you are free to deselect me if you wish and also select the other 9 participants you would like to vote for.  After this just follow on through the survey and click Submit to finish.

Obviously with PowerShell I could have just added my favorite bloggers to this script and completed the survey for you but that would be cheating and I believe in the freedom to vote!

So if you have not yet voted then simply paste the following code into a PowerShell window and watch it control internet explorer and automatically select Virtu-Al from the list, the other choices are up to you!

$URL = "http://www.surveygizmo.com/s3/786135/Top-VMware-virtualization-blogs-2012"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.navigate($URL) 
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.Document.getElementById("sg_NextButton").click()
$ie.Document.getElementById("sgE-786135-1-27-10906").Click() # Click Virtu-Al

8 thoughts on “Using PowerShell with Internet Explorer”

  1. Why not use the Selenium Internet Explorer driver for navigating a site with PowerShell (look up Jaykul)

  2. By just adding the following line you will have 1 less site to chose by yourself 😉

    $ie.Document.getElementById(“sgE-786135-1-27-10848”).Click() # Click Luc Dekens

Leave a Reply