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

Steve.Spreyer

Many thanks for your reply but I managed to resolve the issue using

$transferOptions.FileMask = "|RESULT*"
$transferResult = $session.GetFiles($remotePath, $localPath, $False, $transferOptions)

instead, as that seems to work with the file mask where as

$transferOptions.FileMask = "|RESULT*"
$synchronizationResult = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::local, $localPath, $remotePath, $False , $transferOptions)

does not.
martin

Re: Power shell script wincsp synchronizedirectories file mask not working

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
wyssp4

Power shell script wincsp synchronizedirectories file mask not working

Hi,
this is my first post to the forum so I hope someone can help.

I have a PowerShell script with the following code

$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::ftp
$sessionOptions.HostName = $Remote_Host
$sessionOptions.UserName = $UserName
$sessionOptions.Password = $Password
$Session.SessionLogPath
$session = New-Object WinSCP.Session
$session.Open($sessionOptions)
$transferoptions= New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*.TXT | RESULT*"

# Synchronize files to local directory, collect results
$synchronizationResult = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::local, $localPath, $remotePath, $False, $TransferOptions)

It works fine except the file mask does not exclude the RESULT* files in the directory. Am I doing something wrong?

WinSCP version is WinSCP 5.7.5
Windows version is server 2012

Many thanks for any help
Steve