Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: VM vs production

It's unlikely that the host key is the culprit. Post logs from GUI for comparison.

Also enable password logging and compare GUI and code logs to double check that you use the same password in both cases.

VM vs production

Yes, I'm connecting to two different servers. That's why you have successful login to VM and fails to the production server.
Yes, I can successfully connect to the production using WinSCP GUI but using the PowerShell code of your guides it fails.
Do you think it can be related to the
being different?
Is there a way I can change the
and test?

Because that is the only difference between the VM and the production

Re: PowerShell code in documentation is not working

But those logs shows connections to different servers. Or what is your VM? I've understood that it is a machine, from where you can connect. Or did you use the VM as a test server? Can you connect to your production server anyhow? In WinSCP GUI? From any other local machine?

Done already

I already set
and the logs are in my previous post.

Thank you

Re: PowerShell code in documentation is not working

Set Session.SessionLogPath and post logs from both environments.

WinSCP portable version

I have download the portable version of WinSCP and I pointed the Add-Type -Path to the \netstandard2.0\WinSCPnet.dll and \net40\WinSCPnet.dll. Still failing for both :(

The error in PowerShell is always the same:
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.

Authentication log (see session log for details):
Using username "a***1".
Access denied.
Authentication failed."
At C:\Users\FMV\Documents\test.ps1:18 char:5
+     $session.Open($sessionOptions)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SessionRemoteException

But the exact same code works on my Test VM environment.
Where can be the problem?

Basic code and logs


I have a version of the code I'm using:
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "1*.***.***.*0"
    UserName = "a*****1"
    Password = "m*********9"
    SshHostKeyFingerprint = "ssh-ed25519 255 eeDKU******************************UNg="
$session = New-Object WinSCP.Session
$session.SessionLogPath = "C:\Users\FMV\Documents\logging.log"
    # Connect
    # Your code
    # From VM to Laptop
    $session.GetFiles("full***********.csv", "C:\Users\fmv\Downloads\" )

And in attach the logs.
I was able to test this code on a VM that I created especially for this issue. Everything works.

– WinSCP Version 5.19.2
– rsa2
– Command: working
– Powershell Script: working

– WinSCP Version 5.17.10
– ssh-ed25519
– Command: working
– PowerShell Script: fails

Can the hotkey be the problem?

Version 5.17.10

I forgot to mention that I'm on I'm on version 5.17.10

PowerShell code in documentation is not working


I've recently try to run the PowerShell code that is mentioned in your documentation:

It fails abruptly.

Is there a way to increase the logs for PowerShell?