Post a reply

Options
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)

Options

Topic review

martin

Re: Exception calling "Open" with "1" argument(s): "Host "....com" does not exist

The sftp://xxxx@yyyyyyyy.com/ is not a hostname. A hostname is yyyyyyyy.com. The xxxxp goes to SessionOptions.UserName.
See also https://winscp.net/eng/docs/library_from_script
zairecrypto

Exception calling "Open" with "1" argument(s): "Host "....com" does not exist

Hello,

I am pretty new in WinSCP/PowerShell.

Im trying to connect to a FTP server using SshHostKeyFingerprint, all parameters are correct because I copied paste from a working WinSCP script.

But when I am trying a very basic $session.open, I'm getting the error message
Exception calling "Open" with "1" argument(s): "Host "....com" does not exist.

Not sure the problem comes from the hostname

Could you please help?

My script:
function test_connect{
    try {
        # Load WinSCP .NET assembly
        Add-Type -Path ".\WinSCP-5.17.10-Automation\WinSCPnet.dll"
 
        # Setup session options
        $sessionOptions = New-Object WinSCP.SessionOptions
        $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
        $sessionOptions.HostName = "sftp://xxxx@yyyyyyyy.com/"
        $sessionOptions.SshHostKeyFingerprint = "ssh-ed25519 256 3D....="       
   
        $session = New-Object WinSCP.Session
        try {
            # Connect
            $session.Open($sessionOptions)
        }
        finally {
            # Disconnect, clean up
            $session.Dispose()
        }
 
        # exit 0
    }
    catch {
        Write-Host "Error: $($_.Exception.Message)"
        # exit 1
    }
}