Differences
This shows you the differences between the selected revisions of the page.
2014-09-23 | 2014-09-23 | ||
consistently using quotes around string arguments (martin) | making ps module example consistent with ours (martin) | ||
Line 85: | Line 85: | ||
<code powershell> | <code powershell> | ||
# Define the options for the WinSCP Session. | # Define the options for the WinSCP Session. | ||
- | $options = New-WinSCPSessionOptions -Hostname "myftphost.org" -Username "user" -password "Pword" -SshHostKeyFingerprint "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | $options = New-WinSCPSessionOptions -Hostname "example.com" -Username "user" -password "mypassword" -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" |
# Open the WinSCP Session with the defined options. | # Open the WinSCP Session with the defined options. | ||
$session = Open-WinSCPSession -SessionOptions $options | $session = Open-WinSCPSession -SessionOptions $options | ||
# Using the open WinSCPSession, download the file from the remote host to the local host. | # Using the open WinSCPSession, download the file from the remote host to the local host. | ||
- | Receive-WinSCPItem -WinSCPSession $session -RemoteItem "./rDir/rFile.txt" -LocalItem "C:\lDir\lFile.txt" | + | Receive-WinSCPItem -WinSCPSession $session -RemoteItem "/home/user/file.txt" -LocalItem "C:\download\" |
# Close the WinSCPSession after completion. | # Close the WinSCPSession after completion. | ||
Close-WinSCPSession -WinSCPSession $session | Close-WinSCPSession -WinSCPSession $session | ||
Line 95: | Line 95: | ||
# Accomplish the same task with one line of code. | # Accomplish the same task with one line of code. | ||
# Piping the WinSCPSession into the Receive-WinSCPItem auto disposes the object after completion. | # Piping the WinSCPSession into the Receive-WinSCPItem auto disposes the object after completion. | ||
- | Open-WinSCPSession -SessionOptions (New-WinSCPSessionOptions -Hostname "myftphost.org" -Username "user" -password "Pword" -SshHostKeyFingerprint "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx") | | + | Open-WinSCPSession -SessionOptions (New-WinSCPSessionOptions -Hostname "example.com" -Username "user" -password "mypassword" -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx") | |
- | Receive-WinSCPItem -RemoteItem "./rDir/rFile.txt" -LocalItem "C:\lDir\lFile.txt" | + | Receive-WinSCPItem -RemoteItem "/home/user/file.txt" -LocalItem "C:\download\" |
</code> | </code> | ||