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

wontolla

win7 powershell Could not load file or assembly winscpnet.dll

Hi, this is my first post.
I am from Mexico and this is my first try integrating WinSCP for an automation ftp tasks.

To this point I am succesfully working with winscp and win10:powershell script to upload and download files from a ftp server.

But I tried this on a Win7 pc and it is not working. Same WinSCP versión and same powershell script. But when I tried to upload a file I got error: "Could not load file or assembly winscpnet.dll"
If I try to upload the file using the WinScp program it works fine.
I tried to install the assembly, with no success.

I am using this powershell script:
# Carga del ensamblado .NET para WinSCP
add-type -Path 'C:\Program Files (x86)\WinSCP\WinSCPnet.dll'

# Configuración de opciones de sesión
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Ftp
HostName = "server"
UserName = "user"
Password = "pass"
}

$sessionOptions.AddRawSettings("AddressFamily", "1")
$session = New-Object WinSCP.Session

try
{
# Conexión
$session.Open($sessionOptions)

# Transferir archivos
$session.GetFiles("/empa/EXIS_EMPA.xlsm", "C:\PEDIDO_EMPA\*").Check()
}
finally
{
$session.Dispose()
}

Any suggestion, please?

Best Regards