Post a reply

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)


Topic review


Seems like I found another way by using the WinSCP module.
Save-Module -Name WinSCP -Path $destination\
Install-Module -Name WinSCP -Force
Import-Module -Name WinSCP
Add-Type -Path "$destination\WinSCP\\lib\WinSCPnet.dll"
$session = New-Object WinSCP.Session
$session.ExecutablePath = "$destination\WinSCP\\bin\WinSCP.exe"

This way you can still set SessionOptions (including all credentials) and doesn't require a download from the WinSCP website. The only downside is that there is a hardcoded version number in there which should be changed when there is a new version.

Scripting download and installation of .Net assembly


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 = ""
$filename = "$destination\"
(New-Object System.Net.WebClient).DownloadFile($source, $filename)

But all I get is a 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.