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

notjordan

Log

Attached is the log for my latest session.
notjordan

TransferOptions FileMask not masking files

I'm writing a script to automate parallel synchronisation, and when trying to set a filemask through TransferOptions it is not working. All files are synchronised regardless of what the mask is. For testing purposes I have preset a mask in the example I will share, but generally my script takes the mask in as an argument.

Here is what I believe to be the relevant section of my powershell script:
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.ParseUrl($sessionUrl)
 
$started = Get-Date
 
Write-Host "Connecting..."
$session = New-Object WinSCP.Session
if($logPath -ne " "){
    $session.SessionLogPath = $logPath
}
$sessionOptions.AddRawSettings("PreserveTimeDirs", "1")
$sessionOptions.Timeout = New-TimeSpan -Seconds 30
$session.Open($sessionOptions)
 
# $transferOptions = New-Object WinSCP.TransferOptions -Property @{
#     FileMask = $fileMask
#     PreserveTimestamp = $true
# }
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "<1Y | *.tmp"
$transferOptions.PreserveTimestamp = $true
 
Write-Host "Comparing directories..."
$differences = $session.CompareDirectories(
    [WinSCP.SynchronizationMode]::Remote,
    $localPath,
    $remotePath,
    $true, 
    $transferOptions 
)

I've tried both methods of setting up TransferOptions present in the snippet and neither worked.

Attached is a text file with all my powershell and I will reply to this with an excerpt of the logging of the session.