Home:ALL Converter>Download file from a url

Download file from a url

Ask Time:2018-09-12T03:31:00         Author:Anil kumar

Json Formatter

I have a set of URLs using which I need to download files which can be of any type. I tried to use below PowerShell script, but the problem with this script is that I need to mention the type of the file. e.g. in below example I had to specify the type as PDF. Is there a way I can download file of any type from a URL to a specified folder?

$Path = "D:\Downloads\test.pdf"

# below url turns into 'https://xyz.abc.com/efg/TempData/data/%7B5a8662ff-1cbf-4141-bc93-c2f65657%7D/G4068.pdf'
$Url = "http://xyz.abc.com/efg/url.asp?SessID=1904B8A0E7B358A45F5422BC751CB763666BAB2F6EE10098823DFC10BCA2051260D63DCC93C0D9E63"

$WebClient = New-Object System.Net.WebClient

Write-Host "Downloading" $Path -ForegroundColor Green

$WebClient.DownloadFile($url, $path)

Author:Anil kumar,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52283008/download-file-from-a-url
yy