I am running this below script to incrementally copy files that have changed on a weekly basis.
The problem I am coming across is that all of the files being copied are being placed on the root of the DataNew directory, and are not getting placed in proper subfolders that exist in the Data folder, even though I am using the recurse tag. Is there something that I maybe need to do with paths?
Here is the script:
foreach ($i in Get-ChildItem C:\Data -recurse)
if ($i.LastWriteTime -lt ($(Get-Date).AddDays(-7)))
Copy-Item $i.FullName C:\DataNew
Parts of the script borrowed from Technet.