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