Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Automation - download all

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set 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 can mark the attachment as private.

In any case, you are probably missing a backslash in "f:\my drive\sftp\"

Automation - download all

Trying to just download all files from the root (/) of the host to a drive (google - g drive).

I couldn't get it going to download to the local, it came back and said it succeeded but nothing was there?
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCPnet.dll"
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = ""
        UserName = "userabc"
        Password = "passabc"
        SshHostKeyFingerprint = "ssh-rsa 2048 P0rBKJMYf1man8NTYvBftJUs5EdvpSyJGSE/S+SxVy4="
    $session = New-Object WinSCP.Session
        # Connect
        # Download files
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
        $transferResult =
            $session.GetFiles("/*", "f:\my drive\sftp", $False, $transferOptions)
        # Throw on any error
        # Print results
        foreach ($transfer in $transferResult.Transfers)
            Write-Host "Download of $($transfer.FileName) succeeded"
        # Disconnect, clean up
    exit 0
    Write-Host "Error: $($_.Exception.Message)"
    exit 1