PowerShell Synchronize mode 'Both' with Transfer Options

Advertisement

johnhamborg
Joined:
Posts:
1
Location:
Earth

PowerShell Synchronize mode 'Both' with Transfer Options

I am struggling to include $TransferOptions when using Synchronize mode 'Both'. I looked through loads of documentation but just couldn't figure out how to make it work in powershell. Thanks for the support!

Here is a snippet of modified code based on the included 'KeepLocalUpToDate' extension.

        Write-Host "Connecting..."
        $session.Open($sessionOptions)
       
       #Setup Transfer Options
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
        $TransferOptions.FilePermissions =  New-Object WinSCP.FilePermissions
        $TransferOptions.FilePermissions.Octal = 0777
        #$TransferOptions.FileMask = "|*.jpg;*.txt"

        while ($True)
        {
            Write-Host "Synchronizing changes..."
            $result =
                $session.SynchronizeDirectories(
                    [WinSCP.SynchronizationMode]::Both, $localPath, $remotePath,[WinSCP.SynchronizationCriteria]:: $TransferOptions )

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum