I wrote this because I wondered if it could be done. I figured it would be pretty difficult to come up with a Powershell hack with IE but as it turned out it took just a little bingling and this is what I came up with:
start 'http://www.inhifistereo.com' Start-Sleep -s 5 Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() } exit
The script opens the browser, waits 5 seconds, then closes the page. Pretty simple I know but I’ll be expanding on this script more in the future. Some possibilities/uses could be:
- Check a web page for content then send an email depending on what’s found
- Keep VPN connection open
- Check if a website is up
I went even farther as to add it to the Task Scheduler and have it run every 30 minutes. There are plenty of blog posts out there outlining how to create a Task in Task Scheduler, but the small hiccup I ran in to was how to run Powershell from the Scheduler.
When you get to the Actions tab add the path to Powershell:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
The “Add arguments” section is where you add the command and path to your .ps1 file:
-Command “& [path to your file without brackets]”
The possibilities are pretty endless here. I don’t know if anyone else will find this useful but I know I will use it.