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.
I got rid of the problem by using version 5.13 instead.
$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()
}
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