Well, it's only going to be one file, so that's a non-issue. I do want it renamed when downloaded anyway.
Will try again and post log.
Will try again and post log.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Session.SessionLogPath
.
download.xls
, so all downloaded files overwrite each other.
$transferResult = $session.GetFiles("/Reports/Report_rptTotalMilesAndRanks_201609*.xls", "c:\users\jonathanf\Desktop\", $False, $transferOptions)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = <redacted>
UserName = <redacted>
Password = <redacted>
SshHostKeyFingerprint = <redacted>
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.GetFiles("/Reports/Report_rptTotalMilesAndRanks_201609*.xls", "c:\users\jonathanf\Desktop\download.xls", $False, $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
Write-Host ("Download of {0} succeeded" -f $transfer.FileName)
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host ("Error: {0}" -f $_.Exception.Message)
exit 1
}
Report_rptTotalMilesAndRanks_201610*Final.csv