Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Powershell script to download images from multiple urls
$images = 'https://foo.jpg', 'https://bar.jpg'
$targetDir = 'C:\foo\bar'
function DownloadFile([Object[]] $sourceFiles,[string]$targetDirectory) {
$wc = New-Object System.Net.WebClient
foreach ($sourceFile in $sourceFiles){
$sourceFileName = $sourceFile.SubString($sourceFile.LastIndexOf('/')+1)
$targetFileName = $targetDirectory + $sourceFileName
$wc.DownloadFile($sourceFile, $targetFileName)
Write-Host "Downloaded $sourceFile to file location $targetFileName"
DownloadFile $images $targetDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.