Power shell script wincsp synchronizedirectories file mask not working

Advertisement

wyssp4
Joined:
Posts:
1
Location:
Ellesmere Port, Cheshire

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,508
Location:
Prague, Czechia

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.

Reply with quote

Steve.Spreyer
Guest

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.

Reply with quote

Advertisement

You can post new topics in this forum