Posted: 2013-10-31 19:46
I'm using the standalone WinSCP with the .NET/Powershell extension in a powershell script. It works reasonably well, but there is sometimes a directory that WinSCP report as being empty (only consisting of ".."), when it is not.
Here is the example code I use:
Add-Type -Path "..\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "ftp.domain.com"
$sessionOptions.UserName = "UserName"
$sessionOptions.Password = "Password"
$sessionOptions.SshHostKeyFingerprint = "ssh-dss 1024 asdfasdfasdfasdfasd random asdfasdfasdf"
$session = New-Object WinSCP.Session
$directoryInfo = $session.ListDirectory("/remote/directory/path")
$dirFiles = $directoryInfo.Files
#$dirFiles would only contain ".." if I iterated over it
# Disconnect, clean up
$_.Exception.Message | out-file $outputFp -encoding ascii -append
Curiously enough, when I ran most of this script by typing out lines (instead of running the script containing them), I think that directory's contents were shown to be correct. So I'm a little confused. Does anyone see any problem with the above code?
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).
To generate log file, set
You can post new topics in this forum
And it's free!