Skip to content

Instantly share code, notes, and snippets.

@rahuldottech
Last active January 7, 2020 18:32
Show Gist options
  • Save rahuldottech/3a2ef4f6cbf86135628b11e6f5d28e43 to your computer and use it in GitHub Desktop.
Save rahuldottech/3a2ef4f6cbf86135628b11e6f5d28e43 to your computer and use it in GitHub Desktop.
Download with powershell. Supports HTTPS.
powershell-download by rahuldottech
License:
MIT license - https://github.com/rahuldottech/license
@echo off
REM Usage:
REM powershell_download.cmd <URL> <FILENAME>
REM by @rahuldottech
powershell ([Net.ServicePointManager]::SecurityProtocol = "[Net.SecurityProtocolType]::tls12, [Net.SecurityProtocolType]::tls11, [Net.SecurityProtocolType]::tls, [Net.SecurityProtocolType]::ssl3") -and (wget %1 -UseBasicParsing -OutFile %2)
@echo off
REM Usage:
REM powershell_download.cmd <URL> <FILENAME>
REM by @rahuldottech
powershell -c [Net.ServicePointManager]::SecurityProtocol = 'Tls12,Tls11,Tls,Ssl3'; iwr %1 -UseB -OutF %2
@echo off
echo Downloading file!
call :psd "https://<URL>/" "<filename>"
echo %errorlevel%
REM %errorlevel% is 0 if download was successful, 1 if failed.
:psd
powershell ([Net.ServicePointManager]::SecurityProtocol = "[Net.SecurityProtocolType]::tls12, [Net.SecurityProtocolType]::tls11, [Net.SecurityProtocolType]::tls, [Net.SecurityProtocolType]::ssl3") -and (wget %~1 -UseBasicParsing -OutFile %~2) >nul
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment