How to export all URLs of Internet Explorer tabs at once (PowerShell)

 

Introduction

This script sample can get all current url of tabs in Internet Explorer and supports automatically open the last opened urls.

Scenarios

When you opened many tabs in Internet Explorer but need to stop for the day, or maybe you just updated your computer followed by the inevitable 'Restart your computer to finish installing updates' message. At this point, you must close the browser session with gazillion tabs, you have to temporarily record the URL of each IE tabs that you want to open in the next session. We usually manually copy of each tab URL, it's really time-consuming. This script will help users to export all Internet Explorer tabs and tab titles. It's really useful for users.

Step 1: Start the PowerShell Console with administrator. To run the script in the Windows PowerShell Console, type the command< Script Path> at the Windows PowerShell Console.

Step 2:  If you want to know how to use this script. You can type the command Get-Help C:\Script\IETabAddress.ps1 -Full to display the entire help file for this function, such as the syntax, parameters, or examples.

 

 

Example

Example 1: Type C:\Script\IETabAddress.ps1 -ExportCsvFile C:\Urls.csv in the Windows PowerShell Console.  This command line shows how to get current url of tabs and export to specified location.

The generated csv file as shown below:

Example

Example 1: Type C:\Script\IETabAddress.ps1 -OpenFile C:\Urls.csv in the Windows PowerShell Console.  This command line shows how to automatically open the last opened urls.

As we can see, all urls are opened in Internet Explorer.

 

Here are some code snippets for your references.

PowerShell
Edit|Remove
$ShellWindows = (New-Object -ComObject Shell.Application).Windows() 
  
Foreach($IE in $ShellWindows) 
{ 
    $FullName = $IE.FullName 
    If($FullName -ne $NULL) 
    { 
        $FileName = Split-Path -Path $FullName -Leaf 
  
        If($FileName.ToLower() -eq "iexplore.exe") 
        { 
            $Title = $IE.LocationName 
            $URL = $IE.LocationURL 
            $IEObj = New-Object -TypeName PSObject -Property @{Title = $Title; URL = $URL} 
            $IEObjs += $IEObj 
        } 
    } 
}

 

 

Prerequisite

Windows PowerShell 2.0

Windows 7 or higher version

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.