Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. # Load WinSCP .NET assembly
  2. Add-Type -Path "WinSCPnet.dll"
  3.  
  4. # Setup session options
  5. $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
  6. Protocol = [WinSCP.Protocol]::Sftp
  7. HostName = "example.com"
  8. UserName = "user"
  9. Password = "mypassword"
  10. SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...="
  11. }
  12.  
  13. $session = New-Object WinSCP.Session
  14.  
  15. try
  16. {
  17. # Connect
  18. $session.Open($sessionOptions)
  19.  
  20. # Upload
  21. $session.PutFiles("C:FileDumpexport.txt", "/tmp/Outbox/").Check()
  22. # file exists, I created the directory and a file for testing.
  23. }
  24. finally
  25. {
  26. # Disconnect, clean up
  27. $session.Dispose()
  28. }
  29.  
  30. Exception calling "Open" with "1" argument(s): "Network error: Invalid argument"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement