Slow copy of large files using PowerShell module

Advertisement

smichelson
Joined:
Posts:
5

Slow copy of large files using PowerShell module

Hello, trying to use the WinSCP PowerShell module to move large files (5-10GB) and copy speeds are very slow (less than 1 GB per hour). Tried moving the same files with the WinSCP Windows application and the copy completes in a few minutes. I've added logs for both PowerShell and Windows application jobs.
Description: Windows App Log
Description: PowerShell log

Reply with quote

Advertisement

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

Re: Slow copy of large files using PowerShell module

Please post complete session log files for both scenarios.

Your "PowerShell" log is debug log, not session log.
And your "GUI" log contains the file transfer only. We need complete session.

Reply with quote

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

Re: Slow copy of large files using PowerShell module

You have timeout set to 0 in the PowerShell session. I'm not sure it's the actual problem, but it definitely doesn't help and it makes the log file mess.
Also, please obfuscate the log files consistently. I cannot know if remoteUser@remoteServer is the same thing as userName@remoteHost or not.
You also use different versions of WinSCP.

Reply with quote

smichelson
Joined:
Posts:
5

Re: Slow copy of large files using PowerShell module

Hey Martin, thanks for looking over the logs. Apologies for the inconsistent obfuscation, the remoteUser@remoteServer and userName@remoteHost accounts are referencing the same account being used to log into the remote server.

In my script I'm using the Timeout parameter for the New-WinSCPSessionOption cmdlet:
New-WinSCPSessionOption -Timeout 600
Is there some other timeout parameter I can set to change the "0" setting you mentioned?

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Slow copy of large files using PowerShell module

You are using 3rd party WinSCP PowerShell module that we have nothing to do with.
But I believe that the -Timeout maps directly to WinSCP .NET assembly SessionOptions.Timeout property, which is of type TimeSpan, not an integer. I believe that PowerShell, when casting an integer to TimeSpan, uses Ticks (one ten-millionth of a second). So 600 might be indeed a very small timeout. Consider using New-TimeSpan instead of an integer.

Reply with quote

smichelson
Joined:
Posts:
5

Re: Slow copy of large files using PowerShell module

The New-TimeSpan worked! The copy job completes in about 2–3 minutes now. Thanks so much for the tip!

For anyone else having this issue, here is what I did:
New-WinSCPSession -SessionOption (
    New-WinSCPSessionOption -Timeout (New-Timespan -Minutes 10))

Reply with quote

Advertisement

You can post new topics in this forum