Wednesday, October 23, 2013

Powershell script to copy selected directories with use of robocopy

#The script to Archive files from one share to another depending from the file last write time (preserving the source directory structure and security)

$mySourceRoot="source directory"
$myDestRoot="destination directory"
set-location $mySourceRoot
foreach ($arg in $myDir)
    #write $arg.LastWriteTime
    if ($mytype.Name -eq "DirectoryInfo")
        if ($arg.LastWriteTime -lt (get-date 2009-01-01))
            write $arg.Name  $arg.lastWritetime
set-location c:\windows\system32
foreach ($arg in $mySortDir)
    .\robocopy.exe $myPath $myDestPath /mir /sec /r:0 | Out-Null

No comments:

Post a Comment