1

I would like to change this PowerShell WinSCP script which is connecting to an SFTP Server, to only download .csv files.

What part of the following portion of the script would I need to change?

# Connect
$session.Open($sessionOptions)

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

1 Answers1

0

Specify a filemask using TranferOptions.FileMask to restrict the synchronization to specific extensions.

$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*.csv"

$synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $False, $False,
    [WinSCP.SynchronizationCriteria]::Time, $transferOptions)
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992