powershell - Method invocation failed method named items -
i having trouble code below. trying figure out how output working user profiles instead of current user. if use $shell.namespace(34) code works (the 2 lines commented out). when try override shell.namespace , manually add path error method items not exist. wondering best way fix or around issue is.
actual error message: method invocation failed because [system.string] doesn't contain method named 'items'.
thanks 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 documentation can create namespace object path string.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774085(v=vs.85).aspx
so can this:
$shell = new-object -comobject shell.application $colprofiles = get-childitem "c:\users\" -name foreach ( $userprofile in $colprofiles ) { [string] $histpath = "c:\users\$userprofile\appdata\local\microsoft\windows\history" $hist = $shell.namespace($histpath) $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" } } } } } }
Comments
Post a Comment