Error: Exception calling "Open" with "1" argument(s): "Connection failed.
hello, I need a solution to this problem:
my code:Error: Exception calling "Open" with "1" argument(s): "Connection failed.
Timeout detected. (control connection)
Connection failed."
param ( $localPath = "C:\TestesWinSCP", $remotePath = "/path/files/" ) try { Add-Type -Path "C:\TestesWinSCP\WinSCPnet.dll" $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::"FTP" HostName = "example.com.br" PortNumber = "990" UserName = "YYYYYY" Password = "********" } $session = New-Object WinSCP.Session try { $session.Open($sessionOptions) $directoryInfo = $session.ListDirectory($remotePath) $latest = $directoryInfo.Files | Where-Object { -Not $_.IsDirectory } | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if ($latest -eq $Null) { Write-Host "No file found" exit 1 } $session.GetFiles( [WinSCP.RemotePath]::EscapeFileMask($latest.FullName), $localPath).Check() } finally { $session.Dispose() } exit 0 } catch { Write-Host "Error: $($_.Exception.Message)" exit 1 }