0

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I was using the powershell ISE for this example. Adding 2> $null on the end appears to have done the trick although not entirely sure why...Guess some side reading is on the cards. Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.