1

I'm trying to write a PowerShell Script to connect to a server that is outside my domain.

Inside the script, I'm passing a PSFTP (PuTTY) Connection string to connect to the server.

I'd like to know how to determine if the connection was successful or it failed? Is there any return code to PSFTP command that the scripts can catch based on which I'll be able to determine?

Thanks.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Scoine
  • 11
  • 2
  • For C/C++ libaries like `libssh` and `libssh2` also exist and are straight forward. I personally used `libssh2` on Windows a while back without much issue. – Fire Lancer Apr 11 '19 at 13:43

1 Answers1

1

psftp returns:

  • 0 on a success
  • 1 on a general failure (like inability to open a script file or failure to open a session specified on a command-line)
  • 2 on a command failure
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992