Home > Enterprise >  Exception calling "DownloadString" with "1' argument<s>
Exception calling "DownloadString" with "1' argument<s>

Time:11-16

I'm newbie to web development learning by myself. I'm not a cs student. I'm following a book called HTML5 in easy steps. There is a lesson called "Building input forms" which uses free Abyss Personal Edition web server and activeperl scripts. I want to install activeperl on my machine. I'm on windows 8.1. Activestate site doesn't offer .exe file anymore instead it offers cli installation for windows 10. site says windows 8.1 also be supported. I tried installing their cli program command for windows which is powershell -Command "& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1')))".

Then I got this error message.[screenshot attached] screenshot

Then I googled the exception and found that powershell wasn't configured to older versions of windows prior to 2019 to work with tls 1.2. https://github.com/dotnet/docs/issues/6873

Any tips on how to work around this problem???

CodePudding user response:

Note:

  • The following is an effective solution for getting the download of the target *.ps1 file to succeed, but additional problems may surface when the successfully downloaded script is executed.

  • Indeed, since you're using PowerShell v4, script execution failed due to dependence on the v5 Expand-Archive cmdlet, as discussed in this answer to your follow-up question.


Enable TLS 1.2 as follows, in a ;-separated statement before the .DownloadString() call:

powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; & ([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1')))"

Note: Since you're only using the PowerShell instance for a single download known to use TLS 1.2, the above enables TLS 1.2 only.


If you also had to preserve the originally enabled protocols:

PowerShell v5 syntax:

powershell -Command "[Net.ServicePointManager]::SecurityProtocol  = 'Tls12'; & ([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1')))"

PowerShell v4- syntax:

powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; & ([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1')))"
  • Related