Using PowerShell, I'm trying to pipe a file list from my local drive so Copy-Items can copy them to a network folder. The following statement does find the files I need, and copies them. However, all path information is lost and they all end up in the same folder. I want each file to be saved in relative path fashion at the destination with its file path from the local disk.
So for example "c:\users\user_name\Documents\file_1.txt" should be copied to "\\server\share\my_folder\users\user_name\Documents\file_1.txt"
My searches have proved fruitless. Can this statement be modified to achieve that?
Get-ChildItem -Path c:\users\user_name -r | ? {!($_.psiscontainer) -AND $_.lastwritetime -gt (get-date).date} | %{Copy-Item -Path $_.fullname -destination "\\server\share\my_folder" -Recurse -Force -Container}
EDIT:
It seems like Copy-Item should be able to do this. The following command works:
Copy-Item -Path c:\users\user_name\Documents -Destination "\\server\share\my_folder" -recurse -Force
This command copies all files, sub-folders and files in the sub-folders found in and under c:\users\user_name\Documents. It then recreates the relative directory structure on the network share. It seems like the $_.fullname parameter from the first command is not being treated in a similar fashion. I'm most certainly not piping file list in the expected manner to Copy-Item. Any other advice?