I am using SynchronizeDirectories likes this:
$synchronizationResult = $session.SynchronizeDirectories( [WinSCP.SynchronizationMode]::Remote, "C:\LocalEmptyFolder", "/Remote/Folder/With/Content, $True, $True, [WinSCP.SynchronizationCriteria]::Either, $transferOptions) $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.PreserveTimestamp = $True
this will sometimes result in this error:
##[error]Exception calling "Check" with "0" argument(s): "Error deleting file
The directory is not empty.
Error code: 18
Error message from server (en): The directory is not empty. "
I have noticed this only happens with a folder that has an underscore in the name. The error occurrs when calling $synchronizationResult.Check().