How to download images using Invoke-Webrequest in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To download the images from the webpage using the Invoke-WebRequest command, we can use the images property from the result to retrieve the images URL, and later we can use the method to download them at the specific location. Consider we have the URI: to retrieve the images.

Once you run the below command, you can see the Images property there.

Invoke-WebRequest -Uri ""

To retrieves the images URL,

$req = Invoke-WebRequest -Uri ""
$req.Images | Select -ExpandProperty src


All the above URLs point to the images, so we can download that.

$wc = New-Object System.Net.WebClient
$req = Invoke-WebRequest -Uri ""
$images = $req.Images | Select -ExpandProperty src
$count = 0
foreach($img in $images){    

The output images will be stored in the C:\temp\WebImages folder.

Updated on 18-Jan-2021 07:26:10