SHARE
TWEET

Untitled

a guest Jun 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top