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

martin

Re: removeFiles option in session.SynchronizeDirectories

The removeFiles is fourth parameter of the Session.SynchronizeDirectories.
You are currently passing $False there. Just replace it with $True.
thething

removeFiles option in session.SynchronizeDirectories

I am trying to do a one-way sync from remote to local and have anything that has been removed from remote also removed from local.

Following the PS example it seems like it would go in here somewhere but I have no idea how to call or reference the param/option.
$session.SessionLogPath = $sessionLogPath
 
# Connect
Write-Host "Connecting..."
$session.Open($sessionOptions)
 
# Synchronize files
Write-Host "Comparing files..."
$synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $destination, "/", $False)
 
# Throw on any error
$synchronizationResult.Check()

Documentation says to use the removeFiles param to enable this functionality. Where does it go? I have looked through https://winscp.net/eng/docs/library_session_synchronizedirectories but the PS example does not detail how one would use these additional options. If this is a rudimentary question, I'm sorry, I am not a programmer, just a network guy trying to get something running.

TIA