Ninja Cowgirl
Ninja Cowgirl

Reputation: 11221

Opening IE tab for bunch of URLs from txt file

I am using following powershell to open bunch of urls. the script only opens the first url and then gives following error. Any idea why? I am using Windows 7 and IE 11.

Error:

Method invocation failed because [System.__ComObject] doesn't contain a method named 'Navigate2'.

Code

Function Open-IETabs { 
   param ( 
   [string[]]$Url    )
   begin { 
   $Ie = New-Object -ComObject InternetExplorer.Application    } 
   process {
   $navOpenInBackgroundTab = 0x1000;
   foreach ($Link in $Url) 
   {
    write-host $Link
   $Ie.Navigate2($Link, $navOpenInBackgroundTab) 
   }   
   }    
   end 
   {        
   $Ie.Visible = $true    }
   }
#$path = read-host 'Enter the path of ppm list file'
$path = "c:\texturl.txt"
$url = gc $path


Open-IETabs -Url $Url

Upvotes: 0

Views: 693

Answers (1)

Ninja Cowgirl
Ninja Cowgirl

Reputation: 11221

It turns out the code is good and PowerShell needs to be open as Administrator.

Upvotes: 1

Related Questions