SynchronizationMode - PowerShell

Advertisement

jnw
Joined:
Posts:
2
Location:
na

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()

Reply with quote

Advertisement

jnw
Joined:
Posts:
2
Location:
na

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! :)

Reply with quote

Advertisement

You can post new topics in this forum