Differences

This shows you the differences between the selected revisions of the page.

2015-01-25 2015-07-10
I updated the module to use parameter names that match the assembly properties, so LocalItem is now LocalPath etc (107.5.184.56) Update examples to refactor of module version 5.7.4.1 (dotps1)
Line 92: Line 92:
<code powershell> <code powershell>
-# Define the options for the WinSCP Session. +# Set credentials to a PSCredential Object. 
-$options = New-WinSCPSessionOptions -Hostname "example.com" -Username &quot;user" -Password "mypassword" -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" +$credential = Get-Credential 
-# Open the WinSCP Session with the defined options. +# Create a WinSCP Session. 
-$session = Open-WinSCPSession -SessionOptions $options +$session = New-WinSCPSession -Hostname "example.com" -Credential $credential -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" 
-# Using the open WinSCPSession, download the file from the remote host to the local host. +# Using the WinSCPSession, download the file from the remote host to the local host. 
-Receive-WinSCPItem -WinSCPSession $session -RemotePath "/home/user/file.txt" -LocalPath "C:\download\" +Receive-WinSCPItem -WinSCPSession $session -Path "/home/user/file.txt" -Destination "C:\download\" 
-# Close the WinSCPSession after completion. +# Remove the WinSCPSession after completion. 
-Close-WinSCPSession -WinSCPSession $session+Remove-WinSCPSession -WinSCPSession $session
</code> </code>
Line 105: Line 105:
<code powershell> <code powershell>
-# Piping the WinSCPSession into the Receive-WinSCPItem auto disposes the object after completion. +# Piping the WinSCPSession into the Receive-WinSCPItem auto disposes the WinSCP.Session object after completion. 
-Open-WinSCPSession -SessionOptions (New-WinSCPSessionOptions -Hostname "example.com" -Username &quot;user" -Password &quot;mypassword" -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx") |  +New-WinSCPSession -Hostname "example.com" -Credential (Get-Credential) -SshHostKeyFingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx") |  
-    Receive-WinSCPItem -RemotePath "/home/user/file.txt" -LocalPath "C:\download\"+    Receive-WinSCPItem -Path "/home/user/file.txt" -Destination "C:\download\"
</code> </code>

Last modified: by dotps1