Topic "SFTP Powershell script problems"

Author Message
inanutshell23

Guest


Hello,
First thanks for such a great tool. I'm having an issue however trying to migrate my winscp script files to using Powershell with the .NET assembly. I have obtained and verified the server host key fingerprint, and am using one of the powershell examples for testing. However I immediately get this error:

Connection has been unexpectedly closed. Server sent command exit status 0.

The winscp scripts from command line work fine. As well as the GUI to this same server. What could I be doing wrong?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Please attach a complete log files, both using assembly and scripting.
_________________
Martin Prikryl
inanutshell23

Guest


I figured out the problem by stumbling across this post: https://winscp.net/forum/viewtopic.php?t=12315

Hopefully this will help others. Being a powershell newbie I was not aware of the need to escape certain characters in strings. If the strings are put in single quotes and not double there is no need to escape those characters. Since my password had an illegal powershell character, I changed it to single quotes and it was fine. This would explain why my winscp script would work fine, but not the powershell script. See this page as well for escaping in powershell: http://www.rlmueller.net/PowerShellEscape.htm
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Thanks for sharing your solution.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License