Comparing directories and making changes according to last modified time in PowerShell -
am trying learn powershell in order write script have been unable learn fast enough. need script in powershell following:
- compare 2 directories, copy on missing files or subdirectories.
- during compare, copy recent file(by last modified time) reference object.
- this script should lead 2 duplicate directories on different servers, both date last modified files , sub dirs.
here little of have come with. compares 2 dirs , determines missing each. pretty basic , no near needs be. pointers appreciated if me along way. thanks.
$test1 = get-childitem -recurse -path c:\test1 $test2 = get-childitem -recurse -path c:\test2 compare-object -referenceobject $test -differenceobject $test2
for requirements use straight robocopy. can call powershell ampersand (call) operator:
& robocopy "c:\test1" "c:\test2" /e /dcopy:t
here link examples: robocopy
Comments
Post a Comment