I have a following PowerShell scripts which is to get a file from remote Linux server to local directory, using psftp
and get
commands. These two commands as standalone, works just fine. However, as a following script copy.ps1
:
psftp myusername@linux-host
get /tmp/file1 D:\folder\file1.dat
quit
I get following output:
C:\Users\myusername\Desktop\copy.ps1
psftp : Using username "myusername".
At C:\Users\myusername\Desktop\copy.ps1:1 char:1
+ psftp myusername@linux-host
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Using username "myusername".:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Pre-authentication banner message from server:
| Authorized uses only. All activity may be monitored and reported.
End of banner message from server
Remote working directory is /home/myusername
So, there are two issues:
First NativeCommandError
and then after the output Remote working directory
the shell just stays there without moving ahead with get
command. I must do ^C
to bring the terminal back.