Script powershell ouverture de multiple URL depuis un excel

solosikoa 0 Reputation points
2023-04-27T04:19:05.97+00:00

Bonjour tous le monde,

Est t'il possible de faire un script PowerShell qui ouvre différent URL puis les ferme depuis un fichier Excel ?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,520 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,331 Reputation points
    2023-04-27T15:03:03.1366667+00:00
    
    Hello there,
    
    Suppose you have a text file "url.txt" located in c:\temp and that each line in the file corresponds to a url you want to open with IE. Then the code below would open each url in the file.
    
    $textfile = "c:\temp\url.txt"
     
    ForEach ($url in Get-Content $textfile) {
        $IE=new-object -com internetexplorer.application
        $IE.navigate2($url)
        $IE.visible=$true
    }
    
    Hope this resolves your Query !!
    
    --If the reply is helpful, please Upvote and Accept it as an answer--
    

  2. Rich Matheisen 46,721 Reputation points
    2023-04-27T15:19:59.4233333+00:00

    If you're working with Excel spreadsheets you should install the ImportExcel module. It makes coding much simpler.

    You haven't stated what information you need from the target URL so the code below just saves the web page(s) in an array.

    Here's an example that does what you asked:

    [array]$x = @()
    Import-Excel C:\junk\urls.xlsx |
        ForEach-Object{
            $x += Invoke-WebRequest $_.URL -UseBasicParsing
        }
    

    Here's a sample spreadsheet:

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.