none
Copy-item files from appdata\local RRS feed

  • Question

  • I am trying to search for and copy files located in the appdata\local directory and I have no idea why this is not working, gci can see the files but when I pipe it through to copy-item nothing happens, any ideas?

    Thanks

    $FilePath2 = "C:\Users\$env:username\AppData"
    $DestDir = "C:\Windows\Installs\DTIC"
    $LogFile = "C:\Windows\Installs\CopyADU.log"
    
    get-childitem $FilePath2 -include *.adu -recurse -force | copy-item -destination $DestDir | Out-File $LogFile -Append -Force

    Friday, May 29, 2015 8:24 PM

Answers

  • Assuming there's nothing wrong with your GCI statement, I think this should work for you.

    get-childitem $FilePath2 -include *.adu -recurse -force | % {  copy-item -source $_.FullName -destination $DestDir } | Out-File $LogFile -Append -Force

    Putting the results of GCI through a foreach-object loop, copying each object.

    • Marked as answer by justin rassi Friday, May 29, 2015 9:08 PM
    • Unmarked as answer by justin rassi Friday, May 29, 2015 9:10 PM
    • Marked as answer by justin rassi Friday, May 29, 2015 9:12 PM
    Friday, May 29, 2015 9:02 PM

All replies

  • Assuming there's nothing wrong with your GCI statement, I think this should work for you.

    get-childitem $FilePath2 -include *.adu -recurse -force | % {  copy-item -source $_.FullName -destination $DestDir } | Out-File $LogFile -Append -Force

    Putting the results of GCI through a foreach-object loop, copying each object.

    • Marked as answer by justin rassi Friday, May 29, 2015 9:08 PM
    • Unmarked as answer by justin rassi Friday, May 29, 2015 9:10 PM
    • Marked as answer by justin rassi Friday, May 29, 2015 9:12 PM
    Friday, May 29, 2015 9:02 PM
  • i made some changes and it started working. thanks.

    $FilePath2 = "C:\Users"

    get-childitem $FilePath2 -include *.adu -recurse -force | copy-item -destination $DestDir | Out-File $LogFile -Append -Force

    Friday, May 29, 2015 9:12 PM
  • Change this:

    $FilePath2 = "C:\Users\$env:username\AppData"

    To this:

    $FilePath2 = "C:\Users\$env:username\AppData\*"


    \_(ツ)_/

    Friday, May 29, 2015 9:15 PM
    Moderator