Info has been sent
I've sent my log to you. Thanks!
Session.SessionLogPath
. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
$transferResult.Check()
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