Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Load WinSCP .NET assembly
- Add-Type -Path "WinSCPnet.dll"
- # Setup session options
- $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
- Protocol = [WinSCP.Protocol]::Sftp
- HostName = "example.com"
- UserName = "user"
- Password = "mypassword"
- SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...="
- }
- $session = New-Object WinSCP.Session
- try
- {
- # Connect
- $session.Open($sessionOptions)
- # Upload
- $session.PutFiles("C:FileDumpexport.txt", "/tmp/Outbox/").Check()
- # file exists, I created the directory and a file for testing.
- }
- finally
- {
- # Disconnect, clean up
- $session.Dispose()
- }
- Exception calling "Open" with "1" argument(s): "Network error: Invalid argument"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement