5

Been trying to open multiple url's in ie browser through powershell script

Currently my code is working In chrome browser, how can i achive the same in ie explorer

$urls=gc "C:actual path of the url folder\url.txt"
foreach($url in $urls){
    start-process chrome.exe $url

}

Can anyone help me on this?

2 Answers 2

7

I think this can help you :

This next code open with default web browser :

$urls = @("https://stackoverflow.com/","https://www.google.com/","https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/")

foreach($url in $urls){
    Start-Process $url
}

This next open in iexplorer :

$urls = @("https://stackoverflow.com/","https://www.google.com/","https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/")

foreach($url in $urls){
    # Start-Process "C:\Program Files (x86)\Internet Explorer\iexplore.exe" $url
    Start-Process iexplore.exe $url
}

Look at thoses link : https://www.thomasmaurer.ch/2017/02/open-website-from-powershell/

**

  • EDIT multi tabs on InternetExplorer :

** Note in Internet Explorer the start process doesn't add new Url (at new tab) to existing instance off IE . If you want to open all urls in same instance off IExplorer you have to try other code and see thoses post :

Open tab in existing IE instance

https://superuser.com/questions/208883/using-powershell-to-open-several-tabs-on-start-up

Sign up to request clarification or add additional context in comments.

Comments

4

You can replace the part with "chrome.exe" in your code with iexplore and it should work.


EDIT: Since the original solution opened links in multiple windows, I have created an updated script that tries to open all the links in same browser window.

$IE = new-object -ComObject "InternetExplorer.Application"
$urls= gc "FILEPATH"
$count=1
foreach ($url in $urls){
    if ($count -eq 1){
        $IE.navigate($url,1)
    }
    else{
        $IE.navigate($url,2048)
    }
    $count++
}

5 Comments

Its working but i have 2 observations 1.Its not opening in single web browser like chrome. 2.Its not opening all the urls
@AbhilashPoojary you can look at this post to open url in same InterExplorer stackoverflow.com/questions/15544839/…
@AbhilashPoojary I think I might have found a way of opening the links in a single browser window . Please look at the edit that I made.
@telsub Thanks for the modifications its working as per my requirement.
@crappyprog This is great. We're experiencing multiple sites throwing intermittent 500 errors, so I was able to create a script to open multiple sites in a single shot. I still have to go through each browser tab to see if the site opened correctly or not. Is there a way to have PowerShell tell me if one of the tabs throws a 500 error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.