1

I have this simple script that works on a laptop:

[Net.ServicePointManager]::SecurityProtocol
[enum]::GetNames([Net.SecurityProtocolType])

$url = "https://www.contextures.com/SampleData.zip"

wget -Uri $url -OutFile "C:\temp\temp.zip"

But when I'm trying to run it on a server I'm always getting this error:

wget : The request was aborted: Could not create SSL/TLS secure channel.

Any ideas what might be causing this? Any help would be appreciated.

I already tried this and still getting the same error message:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
10

2 Answers 2

1

Set it to TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
0
0

You can give a try with this example while adding $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12';


cls
$Folder = "$Env:Temp\DownloadFolder\"
# We create a SubFolder Named "DownloadFolder" in the temporary file %Temp% if it doesn't exists yet !
If ((Test-Path -Path $Folder) -eq 0) { New-Item -Path $Folder -ItemType Directory | Out-Null }

$urls=@('https://www.contextures.com/SampleData.zip',
'https://cdn2.unrealengine.com/Fortnite%2FBoogieDown_GIF-1f2be97208316867da7d3cf5217c2486da3c2fe6.gif'
)

$start_time = Get-Date
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12';
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols;

$i = 0
foreach($url in $urls)
{
    $i = $i + 1
    $output = $Folder + $url.Split("/")[-1]

Try {
        Write-Host "$i - Downloading" $output.Split("\")[-1] from $url
        (New-Object System.Net.WebClient).DownloadFile($url,$output)
    }

Catch

    {
        Write-Host "Error in : " $url -ForegroundColor Red -BackgroundColor Yellow
        Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red -BackgroundColor Yellow
        $i = $i - 1
    }
}

Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s) to download $i files"
ii $Folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.