PowerShell and version 5.11

Advertisement

Anthony2233
Guest

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

Reply with quote

Advertisement

Phantonym040
Joined:
Posts:
1

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.

Reply with quote

Advertisement

You can post new topics in this forum