Connect to FTP via Proxy
Hi
I'm trying to connect to an FTP server and have to do I via a proxy server.
I can connect to my internal server via below powershell and get the files I need but when I add
I do get a connection failed.
I use the same code to connect to the external FTP with the added SessionOptions.AddRawSettings .....
Can any one help ?
I know that the firewall and proxy do work as I can connect via the GUI and via CLI with below command as well
I'm trying to connect to an FTP server and have to do I via a proxy server.
I can connect to my internal server via below powershell and get the files I need but when I add
$sessionOptions.AddRawSettings("ProxyMethod", "3") $sessionOptions.AddRawSettings("ProxyHost", "proxy server ip") $sessionOptions.AddRawSettings("ProxyPort", "8080")
I use the same code to connect to the external FTP with the added SessionOptions.AddRawSettings .....
Can any one help ?
I know that the firewall and proxy do work as I can connect via the GUI and via CLI with below command as well
WinSCP.exe ftp://ipaddress-of-remote-ftp -rawsettings ProxyMethod=3 ProxyHost=proxy-ip-address ProxyPort=8080
# Load WinSCP .NET assembly Add-Type -Path "C:\_install\WinSCP-5.17.9-Automation\WinSCPnet.dll" # Setup session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::ftp HostName = "ftp.examlpe.cp," UserName = "username" Password = "mypassword" } $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) # Get list of files in the directory $directoryInfo = $session.ListDirectory($remotePath) # Select the most recent file # some more code