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

martin

Re: Win7 PowerShell Could not load file or assembly winscpnet.dll

You didn't post complete error message, so it's hard to help. You might be having one of these problems:

If neither helps, please post complete exact error message.
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 successfully working with WinSCP and Win10 PowerShell script to upload and download files from an FTP server.

But I tried this on a Win7 PC and it is not working. Same WinSCP version 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