Link to home
Create AccountLog in
Avatar of RayT
RayTFlag for United States of America

asked on

Two-Way Folder Sync Using Powershell

Is there a way to create a Powershell script that will perform a two-way folder sync?  I tried Robocopy and could not get it to work.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

How did Robocopy fail?
Is there a way to create a Powershell script that will perform a two-way folder sync?  I tried Robocopy and could not get it to work.

I agree with Paul, this is Robocopy's bread and butter. If you're having trouble with it refer to this excellent guide.

https://adamtheautomator.com/robocopy-the-ultimate/

Hello I'd created a script on powershell to do this:
https://gallery.technet.microsoft.com/scriptcenter/Copy-Files-from-folderA-to-29710ef9

This creates copies of fiels and folders  oneway and preserves permissions.

Avatar of RayT

ASKER

Here's what I have.  Is this correct?

function Sync($sourceFolder, $targetFolder, $filter) {
    ROBOCOPY $sourceFolder $targetFolder $filter /XO /E /S /FFT /Z /XA:H /W:2 /R:5 /NP /NJH /NJS /NDL /NC /NS

    ROBOCOPY $targetFolder $sourceFolder $filter /XO /E /S /FFT /Z /XA:H /W:2 /R:5 /NP /NJH /NJS /NDL /NC /NS
}
Avatar of RayT

ASKER

I have my Workstation at home and a Laptop I take on the road.  I'm using a USB Drive & Powershell to keep the two computers in sync.
ASKER CERTIFIED SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Are you getting an error message?  What message are you getting?
Avatar of RayT

ASKER

Thanks!