Thanks for the example this works for me. With my limited understanding I am not sure how I am to know the argument order for options.
Just follow the documentation:
https://winscp.net/eng/docs/library_session_synchronizedirectories
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Thanks for the example this works for me. With my limited understanding I am not sure how I am to know the argument order for options.
$session = New-Object WinSCP.Session
# Will continuously report progress of synchronization
$session.add_FileTransferred( { FileTransferred($_) } )
# Connect
$session.Open($sessionOptions)
#This gives the error and keeps going
$session.add_QueryReceived( {
LogWrite $($_.Message)
$_.Continue()
} )
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "| ~*"
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote,
"\\Development\Forms\", "/Forms/", $False,
$False, [WinSCP.SynchronizationCriteria]::Time, $transferOptions)
options
is 7th argument of SynchronizeDirectories
, not 5th.
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote,
"C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
$False, [SynchronizationMode.SynchronizationCriteria]::Time,
$transferOptions)
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "| ~*"
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote,
"C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
$transferOptions)
~
in the name.
WinSCP.SessionRemoteException: Can't open file 'C:\Users\1234\desktop\testupload\~$New...
PS C:\Users\1234> $transferOptions
PreserveTimestamp : True
FilePermissions :
TransferMode : Binary
FileMask : | ~*
ResumeSupport : default
SpeedLimit : 0
OverwriteMode : Overwrite
| ~*
, not ~*
# Synchronize files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "~*"
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote,
"C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
$transferOptions)
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote,
"C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
"|~*")
~
using a filemask | ~*
.
Session.QueryReceived
to continue on error:
~$Automated.xlsx
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "\\toys.com\data","/data/",
$False)
System Error. Code: 32.
The process cannot access the file because it is being used by another process
Permissions of kept with their defaults
Timestamp of kept with its default (current time)
Error: Exception calling "Check" with "0" argument(s): "Can't open file '\\toys.com\data\Cases\~$Automated.xlsx'.
System Error. Code: 32.
The process cannot access the file because it is being used by another process