Powershell Filemask not working Synchronize directories

Advertisement

smartel
Joined:
Posts:
3

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
}

Reply with quote

Advertisement

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

Re: Powershell Filemask not working Synchronize directories

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

smartel
Joined:
Posts:
3

Re: Powershell Filemask not working Synchronize directories

Here is the log file,

Thanks!
  • winscp.log (31.25 KB, Private file)

Reply with quote

smartel
Joined:
Posts:
3

Re: Powershell Filemask not working Synchronize directories

Thanks!

Makes sense, here is what I use if others can use it, the 1 in there is to use the time option for criteria, did not find a nicer way to pass it on!, but it works !:

.
.
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "d:\temp", "/", $True, $False, 1, $TransferOptions)
.
.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum