Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

jnw

Re: SynchronizationMode - PowerShell

martin wrote:

Just use $True for the removeFiles parameter (4th) of Session.SynchronizeDirectories:

$session.SynchronizeDirectories(

[WinSCP.SynchronizationMode]::Remote, $localPath, $remotePath, $True)

See https://winscp.net/eng/docs/library_session_synchronizedirectories


Thank you for spending the time to reply. This worked. It's also helped me understand the documentation page you linked a lot more. Didn't clock the parameters were relative to that part of the code. I'm pretty new! :)
jnw

SynchronizationMode - PowerShell

So I have the sync from my local to remote folders working, and it transfers any missing files into the remote folders.

I am however unable to get the sync to remove files out of the remote folders which are not present on the local folders. I have found examples for -delete but this isn't workable in the winscp powershell module I am using...

any help or point into the right location would be greatly appreciated. Below is part of what I am using...

#sync files from usb to remote path
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, $localPath, $remotePath, $False)

# Throw on any error
$synchronizationResult.Check()