SFTP and Powershell: Invalid argument to time encode
Using WinSCP v5.1.2 build 2816
Powershell 2.0
I keep getting a failure on uploads. My SFTP function is below. I've read that it could be due to high timeout, but mine isn't set very high. Anyone have any ideas?
* 2013-09-25 08:48:56.406 (ECommand) Copying files to remote side failed.
* 2013-09-25 08:48:56.406 Invalid argument to time encode
< 2013-09-25 08:48:56.406 Script: Copying files to remote side failed.
< 2013-09-25 08:48:56.406 Script: Invalid argument to time encode
. 2013-09-25 08:48:56.406 Script: Failed
> 2013-09-25 08:48:56.516 Script: exit
. 2013-09-25 08:48:56.516 Script: Exit code: 1
. 2013-09-25 08:48:56.516 Closing connection.
. 2013-09-25 08:48:56.516 Sending special code: 12
Powershell 2.0
I keep getting a failure on uploads. My SFTP function is below. I've read that it could be due to high timeout, but mine isn't set very high. Anyone have any ideas?
* 2013-09-25 08:48:56.406 (ECommand) Copying files to remote side failed.
* 2013-09-25 08:48:56.406 Invalid argument to time encode
< 2013-09-25 08:48:56.406 Script: Copying files to remote side failed.
< 2013-09-25 08:48:56.406 Script: Invalid argument to time encode
. 2013-09-25 08:48:56.406 Script: Failed
> 2013-09-25 08:48:56.516 Script: exit
. 2013-09-25 08:48:56.516 Script: Exit code: 1
. 2013-09-25 08:48:56.516 Closing connection.
. 2013-09-25 08:48:56.516 Sending special code: 12
Function sftp { Try { [Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\WinSCP\WinSCP.dll") | Out-Null $sessionOptions = New-Object WinSCP.SessionOptions $sessionOptions.Protocol = [WinSCP.Protocol]::sftp $sessionOptions.PortNumber = 22 $sessionOptions.Timeout = "120" $sessionOptions.HostName = $host $sessionOptions.UserName = $user $SessionOptions.SshPrivateKeyPath = "prv.ppk" $sessionOptions.SshHostKeyFingerprint = $fingerprint $session = New-Object WinSCP.Session $exportFile = dir "D:\export" | Select -ExpandProperty name $arrExport = @() ForEach ($file in $exportFile) { $arrExport += ("D:\export\" + $file) } $session.SessionLogPath = ("D:\TestSFTP.log") Try { $session.Open($sessionOptions) $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary ForEach ($ufile in $arrExport) { #$transferResult = $session.PutFiles($ufile, "/", $FALSE, $transferOptions) $transferResult = $session.PutFiles($ufile, "/") $transferResult.Check() ForEach ($transfer in $transferResult.Transfers) { Write-Host ("Upload of {0} succeeded" -f $transfer.FileName) } } } Finally { $session.Dispose() } } Catch [Exception] { Write-Host $_.Exception.Message exit 1 } } sftp