Differences
This shows you the differences between the selected revisions of the page.
script_download_most_recent_file 2021-03-05 | script_download_most_recent_file 2022-06-16 (current) | ||
Line 8: | Line 8: | ||
<code powershell> | <code powershell> | ||
param ( | param ( | ||
- | $localPath = "c:\downloaded\", | + | $localPath = "c:\downloaded", |
- | $remotePath = "/home/user/" | + | $remotePath = "/home/user" |
) | ) | ||
Line 23: | Line 23: | ||
UserName = "user" | UserName = "user" | ||
Password = "mypassword" | Password = "mypassword" | ||
- | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...=" | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
} | } | ||
Line 51: | Line 51: | ||
# Download the selected file | # Download the selected file | ||
- | $session.GetFiles( | + | $session.GetFileToDirectory($latest.FullName, $localPath) | Out-Null |
- | [WinSCP.RemotePath]::EscapeFileMask($latest.FullName), $localPath).Check() | + | |
} | } | ||
finally | finally | ||
Line 89: | Line 88: | ||
UserName = "user", | UserName = "user", | ||
Password = "mypassword", | Password = "mypassword", | ||
- | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...=", | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...", |
}; | }; | ||
Line 97: | Line 96: | ||
session.Open(sessionOptions); | session.Open(sessionOptions); | ||
- | const string remotePath = "/home/user/"; | + | const string remotePath = "/home/user"; |
- | const string localPath = @"C:\downloaded\"; | + | const string localPath = @"C:\downloaded"; |
// Get list of files in the directory | // Get list of files in the directory | ||
Line 117: | Line 116: | ||
// Download the selected file | // Download the selected file | ||
- | session.GetFiles( | + | session.GetFileToDirectory(latest.FullName, localPath); |
- | RemotePath.EscapeFileMask(latest.FullName), localPath).Check(); | + | |
} | } | ||