Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming output from Invoke-WebRequest to screen

I am trying to invoke a web request which will print out a stream of plain-text live. It currently works, but doesn't produce any output until the request is complete. I'm trying to find a way to see the content as soon as comes down the wire. I can currently do with with a curl command from a Linux box and it shows be each line of output as soon as it's produced. The PowerShell command I'm trying to use it something like this:

Invoke-WebRequest -Body @{id=123} -Method POST -Uri http://server/run_command/

The corresponding curl command on Linux is:

curl -d id=123 -X POST http://server/run_command/ --no-buffer

The --no-buffer option is only needed when sending the output to another command like grep. How can I accomplish this using just PowerShell?

like image 970
penguin359 Avatar asked Oct 13 '17 18:10

penguin359


1 Answers

I am not able to test this myself right now, but have you tried expanding the content?

(Invoke-WebRequest -Body @{id=123} -Method POST -Uri http://server/run_command/).Content
like image 150
Local Needs Avatar answered Nov 15 '22 10:11

Local Needs