SFTP Powershell script problems

Advertisement

inanutshell23
Guest

SFTP Powershell script problems

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?

Reply with quote

Advertisement

inanutshell23
Guest

Figured out the problem

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: https://www.rlmueller.net/PowerShellEscape.htm

Reply with quote

Advertisement

You can post new topics in this forum