.NET assembly TransferOption to limit speed of transfers

Advertisement

Guest

.NET assembly TransferOption to limit speed of transfers

Hello. I am using the example PowerShell script from the .NET assembly documentation to synchronize directories, and I want to limit the bandwidth of the transfers. I have added the following lines for the TransferOptions:
$transferoptions = New-Object WinSCP.TransferOptions
$transferoptions.SpeedLimit = '1024'
And I added the $transferoptions to the end of the synchronize line:

$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Local, "C:\TestDirectory",
        "/Test/Data/", $False, $transferoptions)
[/code]
However, the transfers still seem to run at max bandwidth. I am assuming I have an incorrect syntax on the synchronization line, but the script does not throw any errors. Can you assist with an example of adding TransferOptions to the SynchronizeDirectories method, please?

I appreciate any guidance.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
42,276
Location:
Prague, Czechia

Re: .NET assembly TransferOption to limit speed of transfers

You are missing mirror and criteria parameters before the options parameter.
To pass the defaults, use:
$synchronizationResult =
    $session.SynchronizeDirectories(
        [WinSCP.SynchronizationMode]::Local, "C:\TestDirectory",
        "/Test/Data/", $False,
        $False, [WinSCP.SynchronizationCriteria]::Time,
        $transferoptions)

See Why are options provided to WinSCP .NET assembly methods in PowerShell being ignored?

Reply with quote

Advertisement

You can post new topics in this forum