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:

  1. compare 2 directories, copy on missing files or subdirectories.
  2. during compare, copy recent file(by last modified time) reference object.
  3. 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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -