Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

acem77

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

I have updated and tried this earlier,
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "| ~*"
   
$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Remote,
        "C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
        $transferOptions)

does the mask work with Synchronization

I see this is set, but I still get the same errors in the log locked files with ~ 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
martin

Your first snippet is almost correct, except that I've suggested | ~*, not ~*

Your second snippet is just wrong.
acem77

Thanks for the reply,
so far I have had no luck and tried the below methods. Do you have a full example? could I have access to the beta?

Thanks
# Synchronize files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "~*"
$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Remote,
        "C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
        $transferOptions)

And
$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Remote,
        "C:\Users\1234\desktop\testupload\", "/BatchAPI/test/", $False,
        "|~*")
acem77

Continue on error while using PowerShell script? "System Error. Code: 32"

Hello,
How can I keep the job running when a file is open while using PowerShell?
would making the change here resolve my issue?
Synchronize Options
https://winscp.net/eng/docs/ui_keepuptodate
and or skip hidden files as this is temp file ~$Automated.xlsx

Example,
$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Remote, "\\toys.com\data","/data/",
        $False)

Thanks
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