Powershell SynchronizationMode speed limit not work

Advertisement

JW
Guest

Powershell SynchronizationMode speed limit not work

I have follow the below link to setup Synchronization by powershell and try to limit the speed. I have enabled the transferOptions object but it not work.....

https://winscp.net/eng/docs/library_session_synchronizedirectories#powershell

try
{
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "example.com"
UserName = "user"
Password = "mypassword"
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
{
# Will continuously report progress of synchronization
$session.add_FileTransferred( { FileTransferred($_) } )

# Connect
$session.Open($sessionOptions)

$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.SpeedLimit = 10

# Synchronize files
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "d:\www", "/home/martin/public_html", $False, $transferOptions)

# Throw on any error
$synchronizationResult.Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}

exit 0
}

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum