Write stream got from Invoke-RestMethod to image file in PowerShell

Question:

I have a Asp.Net Web API which can return image stream to client.

With fiddler, I can see the image was downloaded successfully. What I want to achieve is save it to local image with PowerShell.

I got the $result, but don’t know how to save it to local disk, I’ve tried these ways:

What the right way to save the image to local with PowerShell?

Answer:

Use -OutFile switch:

You could also use Invoke-WebRequest instead of Invoke-RestMethod.

Source:

Write stream got from Invoke-RestMethod to image file in PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply