3

I'm trying to download an image from the internet using a command prompt like PowerShell or the Windows command line.

I tried running this line that I found online:

wget http://imgur.com/ -OutFile out.jpg

That's an example, not the actual parameters that I used.

I ran this in PowerShell, but I get

System.UnauthorizedAccessException

I'm not very experienced in the command line and don't know what to do from here.

Mofi
  • 46,139
  • 17
  • 80
  • 143
Trocadero
  • 37
  • 1
  • 4
  • 1
    Have you considered this answer: https://stackoverflow.com/questions/22447326/powershell-download-image-from-an-image-url – websch01ar Oct 30 '18 at 11:31
  • 2
    Possible duplicate of [Powershell - Download Image from an image url](https://stackoverflow.com/questions/22447326/powershell-download-image-from-an-image-url) – phrogg Oct 30 '18 at 11:32
  • `http://imgur.com/` is clearly not the url of an image. Is that really the url you used? – marsze Oct 30 '18 at 11:41
  • While you've included _some_ code it's not the actual code you're using, you've also only included part of the error message - both of these hinder any meaningful answer to your question. I'd recommend reading [ask] and the [Question Checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) as at the moment your question is missing the basics that are expected when asking a question. It's likely to be downvoted and closed until you include these basics. – henrycarteruk Oct 30 '18 at 11:42
  • wget is in this case an alias for invoke-webrequest, which won't run in a cmd.exe shell... – Peter Schneider Oct 30 '18 at 13:22
  • @PeterSchneider - Perhaps aliases are more trouble than benefit. – lit Oct 30 '18 at 14:50

2 Answers2

2

Use Invoke-WebRequest:

Invoke-WebRequest -Uri https://i.imgur.com/XoSe08F.jpg -OutFile test.jpg -UseBaseParsing

In case of Edge or Internet Explorer is not installed use the -UseBaseParsing switch, otherwise Invoke-WebRequest might fail.

Moerwald
  • 10,448
  • 9
  • 43
  • 83
1
Pebbled
  • 11
  • 2