I have a backup Folder F:\DATA\01172014 - this folder has five sub dirs \Folder1, \Folder2, Folder3, Folder4, Folder5
F:\DATA\01172014.. ..\Folder1 ..\Folder2 ..\Folder3 ..\Folder4 ..\Folder5
I want to copy the the folders 1 through 5 to the E:\Main location overwriting the existing folders
E:\Main ..\Folder1 ..\Folder2 ..\Folder3 ..\Folder4 ..\Folder5
My problem is when I run the script it finds the 01172014 folder and copy's it to the E:\Main as the same name and does not overwrite the old folders
E:\Main ..\01172014 ..\Folder1 ..\Folder2 ..\Folder3 \Folder4 ..\Folder5
My question is what am I missing
Here is my code I am using :-
Get-ChildItem -Path F:\DATA -r |
Where-object {$_.PSIscontainer -and (($_.lastwritetime.date -eq ((get-date).adddays(-1)).date))} |
% { Copy-Item $_.fullName -destination E:\Main\ -force -R -whatif}