PowerShell copy fails without warning

Posted by boink on Stack Overflow See other posts from Stack Overflow or by boink
Published on 2010-03-20T11:07:13Z Indexed on 2010/03/20 11:11 UTC
Read the original article Hit count: 234

Filed under:
|

Howdy, am trying to copy a file from IE cache to somewhere else. This works on w7, but not Vista Ultimate.

In short:

copy-item $f -Destination "$targetDir" -force

(I also tried $f.fullname)

The full script:

$targetDir = "C:\temp"
$ieCache=(get-itemproperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders").cache

$minSize = 5mb
Write-Host "minSize:" $minSize
Add-Content -Encoding Unicode -Path $targetDir"\log.txt" -Value (get-Date)

Set-Location $ieCache
#\Low\Content.IE5 for protected mode
#\content.ie5 for unprotected

$a = Get-Location 

foreach ($f in 
        (get-childitem -Recurse -Force -Exclude *.dat, *.tmp | where {$_.length -gt $minSize})
        )
        {           
        Write-Host (get-Date)   $f.Name $f.length       
        Add-Content -Encoding Unicode -Path $targetDir"\log.txt" -Value $f.name, $f.length
        copy-item $f -Destination "$targetDir" -force
        }

End of wisdom. Please help!

© Stack Overflow or respective owner

Related posts about copy-item

Related posts about powershell