I am trying to copy a large number of files from a Windows system to a Unix share using PowerShell. I seem to be able to get so far, but not the whole solution.
I seem to be able to copy the files across as long as I don't mind where they are stored as it loses all folder structure. I have tried various methods posted here and elsewhere online to no avail.
Code:
gci -path "e:\company folders\\*" | Where-Object {$_.LastAccessTime -le (Get-Date).addyears(-2)} | Copy-Item -destination "\\\networkfolder\archive\company folders\"
I have tried several variations of this script, including using -recurse after the -path and after the -destination
The most success came from
gci -path "e:\company folders\*" | Where-Object {$_.lastaccesstime -le (Get-Date).addyears(-2)} | Copy-Item -destination "\\\networkshare\archive\company folder\" -recurse -container
But this only copied five out of the 43 folders..
What am I doing wrong?