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:
Error:
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