Topic "Scripting download and installation of .Net assembly"

Author Message
Aeschere
[View user's profile]

Joined: 2017-07-26
Posts: 2
Hello,

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

Code:
$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.
Aeschere
[View user's profile]

Joined: 2017-07-26
Posts: 2
Seems like I found another way by using the WinSCP module.

Code:
Save-Module -Name WinSCP -Path $destination\
Install-Module -Name WinSCP -Force
Import-Module -Name WinSCP

Add-Type -Path "$destination\WinSCP\5.9.6.0\lib\WinSCPnet.dll"

$session = New-Object WinSCP.Session
$session.ExecutablePath = "$destination\WinSCP\5.9.6.0\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.

[/quote]
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
Download the file from SourceForce, as shown here:
https://superuser.com/q/1192445/213663#1192463

Your other post does not make any sense to me.
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License