I developed a PowerShell script, and it's working absolutely fine. The only challenge is the files in the subfolders are not getting moved to the destination.
get-childitem -Path "\\servername\location" |
where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} |
move-item -destination "C:\Dumps"
I am unable to customize the script further.
Use the
-Recurse
option on theGet-ChildItem
command to get through to the files in the sub folders and then move each individually by piping the collection toMove-Item
Here's a screenshot:
Don't waste your time trying to re-invent
robocopy
in PowerShell.Simplification of the above
robocopy A:\ B:\ /MIR /minage:31
Where A:\ is your source B:\ is your destination
I needed a quick one liner to move all data off one drive onto another. This worked perfectly for me:
Get-ChildItem "E:" -Recurse | Move-Item -Destination "G:"