0
votes
PS C:\> $p = New-Object System.Net.WebClient

PSC:\>$p.DownloadFile("https://upload.wikimedia.org/wikipedia/en/e/ec/Soccer_ball.svg","C:Users\Tamil\Downloads\Soccer_ball.svg.jpg")
 Exception calling "DownloadFile" with "2" argument(s): "An
exception occurred during a WebClient request."

At line:1 char:1
+ $p.DownloadFile("https://upload.wikimedia.org/wikipedia/en/e/ec/Socce
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException 

enter image description here

1
The local path is not valid. C:Users\Tamil\Downloads\Soccer_ball.svg.jpg", you're missing a backslash after C:.Ash

1 Answers

0
votes

As Ash already mentioned in comment that local path is not valid and you need to provide the same extension as the image to download. So that you can download the image properly and able to view it.

I was able to download the image using:

$p.DownloadFile("https://upload.wikimedia.org/wikipedia/en/e/ec/Soccer_ball.svg","C:\test.svg")