I am having some trouble with the code below. I am trying to figure out how to get the output working for all user profiles instead of just the current user. If I use the $shell.NameSpace(34) the code works (the two lines commented out). But when I try override the shell.namespace and manually add the path I get an error that the method items does not exist. Wondering what the best way to fix or get around this issue is.
Actual error message: Method invocation failed because [System.String] doesn’t contain a method named ‘Items’.
Thanks for the help in advanced.
$shell = New-Object -ComObject Shell.Application
$colProfiles = Get-ChildItem "C:\Users\" -Name
#$hist = $shell.NameSpace(34)
#Write-Host $hist
foreach ( $userProfile in $colProfiles )
{
[string]$hist = "C:\Users\$userProfile\AppData\Local\Microsoft\Windows\History"
$date = ""
$url = ""
$hist.Items() | foreach {
""; "";
if ($_.IsFolder)
{
$siteFolder = $_.GetFolder
$siteFolder.Items() | foreach {
$site = $_
"";
if ($site.IsFolder)
{
$pageFolder = $site.GetFolder
Write-Host $pageFolder
$pageFolder.Items() | foreach {
$url = $pageFolder.GetDetailsOf($_,0)
$date = $pageFolder.GetDetailsOf($_,2)
echo "$date $url"
}
}
}
}
}
}
According to the documentation you can create a namespace object from a path string.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774085(v=vs.85).aspx
So you can do this: