IE history to CSV
Back in April last year I wrote a post about viewing IE history
http://msmvps.com/blogs/richardsiddaway/archive/2010/04/13/ie-history.aspx
I had a comment left asking how this could be put into a CSV file
We’ll start by turning the script into an advanced function that outputs an object
function get-iehistory {
[CmdletBinding()]
param ()
$shell = New-Object -ComObject Shell.Application
$hist = $shell.NameSpace(34)
$folder = $hist.Self
$hist.Items() |
foreach {
if ($_.IsFolder) {
$siteFolder = $_.GetFolder
$siteFolder.Items() |
foreach {
$site = $_
if ($site.IsFolder) {
$pageFolder = $site.GetFolder
$pageFolder.Items() |
foreach {
$visit = New-Object -TypeName PSObject -Property @{
Site = $($site.Name)
URL = $($pageFolder.GetDetailsOf($_,0))
Date = $( $pageFolder.GetDetailsOf($_,2))
}
$visit
}
}
}
}
}
}
The main changes are to stop writing strings to the output and to create an object to put the data into.
Run the function by dot sourcing the file you have the script in – its easier to do this in ISE Then try these commands
get-iehistory
get-iehistory | export-csv iehistory.csv -TypeInformation
Import-Csv iehistory.csv