Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell script to move files and folders including subfolders from one location to another older than x days

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.

like image 216
user1926332 Avatar asked Feb 18 '13 11:02

user1926332


1 Answers

Don't waste your time trying to re-invent robocopy in PowerShell.

robocopy \\servername\location C:\Dumps /e /mov /minage:31
like image 138
Ansgar Wiechers Avatar answered Oct 09 '22 17:10

Ansgar Wiechers