ricky89
ricky89

Reputation: 1396

error when running psftp with Powershell

I am calling psftp.exe from a powershell script and whilst it downloads the specified file/s correctly and functions as expected, the error (below) is thrown to the command line output which as far as I can tell has no material impact on the process as a whole.

.\psftp.exe : Looking up host "hostname.com"
At line:2 char:1
+ .\psftp.exe 'hostname.com' -l 'username' -pw 'password ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Looking up host "hostname.com":String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Connecting to <HostIP> port <PortNo.>
Server version: <Version>
Using SSH protocol <Version>
We claim version: <Version>
Host key fingerprint is:
<key>
Using username "<username>".
Attempting keyboard-interactive authentication
Access granted
Opening session as main channel
Opened main channel
Started a shell/command
Sent EOF message
Server sent command exit status 0
Disconnected: All channels closed

Does anyone know what this error is suggesting. Surely if any of the credentials being passed were wrong the session wouldn't connect and download the files correctly?

The script is below for completeness:

.\psftp.exe 'hostname.com' -l 'username' -pw 'Pass' -P 'portNo' -v -b 'GetFiles.txt' # -be -bc

Based on the response marked as the solution, I have amended to (.\psftp.exe 'hostname.com' -l 'username' -pw 'Pass' -P 'portNo' -v -b 'GetFiles.txt') 2> $null

Upvotes: 0

Views: 2869

Answers (1)

BartekB
BartekB

Reputation: 8650

Looks like all verbose messages are written to stderr (easy to confirm by running the same command with 2> $null at the end).

In "normal" PowerShell.exe it shouldn't be visible, ISE will encapsulate anything that shows up in standard error in exceptions (as you've noticed).

Are you running psftp.exe in PowerShell ISE? If yes you may want to use one of techniques I've suggested for similar problem with git in ISE.

Upvotes: 3

Related Questions