Avatar of RayT
RayT
Flag 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.
Powershell

Avatar of undefined
Last Comment
RayT

8/22/2022 - Mon
Paul MacDonald

How did Robocopy fail?
Aard Vark

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/
Jose Gabriel Ortega Castro

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.

Your help has saved me hundreds of hours of internet surfing.
fblack61
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
}
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
Paul MacDonald

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
serialband

Are you getting an error message?  What message are you getting?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
RayT

ASKER
Thanks!