Powershell Filemask not working Synchronize directories
Good day All!
I am trying to synchronize directories, including only files starting with Backup_ , with a powershell script, but it seems to ignore my filemask, here it is, any help welcome!:
[Reflection.Assembly]::LoadFrom("\\d:\temp\WinSCPnet.dll") | Out-Null
# Main script
try
{
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "sftpserver"
$sessionOptions.PortNumber = "222"
$sessionOptions.UserName = "ftpusername"
$sessionOptions.Password = "pwd"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
$transferoptions= New-Object WinSCP.TransferOptions
$TransferOptions.FileMask = "Backup_*.zip|*/"
# Synchronize files
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "d:\temp", "/", $True, $transferoptions)
# Throw on any error
$synchronizationResult.Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}
I am trying to synchronize directories, including only files starting with Backup_ , with a powershell script, but it seems to ignore my filemask, here it is, any help welcome!:
[Reflection.Assembly]::LoadFrom("\\d:\temp\WinSCPnet.dll") | Out-Null
# Main script
try
{
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "sftpserver"
$sessionOptions.PortNumber = "222"
$sessionOptions.UserName = "ftpusername"
$sessionOptions.Password = "pwd"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
$transferoptions= New-Object WinSCP.TransferOptions
$TransferOptions.FileMask = "Backup_*.zip|*/"
# Synchronize files
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "d:\temp", "/", $True, $transferoptions)
# Throw on any error
$synchronizationResult.Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}