I am trying to write a script that I can use to automatically install and configure a brand new Windows server. One of the key components for this is WinSCP so that I can download the required files from our FTP server.
When I am using the WinSCP module I am able to download the files but this requires me to manually provide credentials for the connection so I am looking for a way to use the .Net assembly.
However, I cannot seem to download the ZIP file from the WinSCP website through a script.
I am currently using this
$source = "https://winscp.net/download/WinSCP-5.9.6-Automation.zip"
$filename = "$destination\winscp.zip"
(New-Object System.Net.WebClient).DownloadFile($source, $filename)
But all I get is a winscp.zip file of 10KB that cannot be opened. When trying to use the CDN or Alternative download link it is possible to download the file but those URL's come with a personalized and times code which causes the download to fail the next time I run the script.
Is there a way to download the file directly?
Thanks in advance.