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

Phantonym040

Little update

My config wasn't compatible with the older version. I think I used version 5.1.1, not 5.11.

I got rid of the problem by using version 5.13 instead.
Anthony2233

PowerShell and version 5.11

I'm using version 5.11 due to an older system. I can't find docs for the older version.

Script:

$ScriptRoot = "$(Split-Path -Parent $MyInvocation.MyCommand.Path)\"


$DLL = $ScriptRoot + "\WinSCP.dll"

Add-Type -Path $DLL

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Ftp
    FtpSecure = [WinSCP.FtpSecure]::Explicit
    #TlsHostCertificateFingerprint = $Fingerprint
    SslHostCertificateFingerprint = $Fingerprint
    HostName = $HostAddress
    UserName = $Username
    Password = $Password
}

$session = New-Object WinSCP.Session

try
{
    $session.Open($sessionOptions)
}
finally
{
    $session.Dispose()
}


Error:

PS C:\Users\Anthony> C:\Users\Anthony\Download.ps1

Running...
New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again.
At C:\Users\Anthony\Download.ps1:26 char:23
+     $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Object], Exception
    + FullyQualifiedErrorId : SetValueException,Microsoft.PowerShell.Commands.NewObjectCommand
 
Exception calling "Open" with "1" argument(s): "The winscp.exe executable was not found at location of the assembly (C:\Users\Anthony),
nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to winscp.exe."
At C:\Users\Anthony\Download.ps1:40 char:9
+         $session.Open($sessionOptions)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SessionLocalException