I just want to replicate the same behavior that I do on Linux systems
c:\> \{CURL_EQUIVALENT_ON_WINDOWS} - http://url/script | powershell
Is that possible?
Basically I want to execute a stream I download from a server.
IE: in steps:
1) Find out how to execute streams in a powershell. Execute a stream (that I already have on the file system)
c:\> type script.ps1 | powershell -command -
but this doesn't work.
There is an option -File to execute a "File", and basically I want to execute the stream if possible.
2) Find out how to execute a stream I download from the server and pipe it in to a powershell.
curl requires minimal user interaction and is therefore preferred for automation. curl in PowerShell uses Invoke-WebRequest . From PowerShell 3.0 and above, you can use Invoke-WebRequest , which is equivalent to curl .
The conclusion is that if you need to use the curl (as same as in the Windows command prompt) in PowerShell then you need to call the curl executable( curl.exe ) directly. Else, you should stick to the PowerShell curl alias which resolves to the Invoke-WebRequest cmdlet under the hood.
The syntax for the curl command is as follows: curl [options] [URL...] In its simplest form, when invoked without any option, curl displays the specified resource to the standard output. The command will print the source code of the example.com homepage in your terminal window.
In PowerShell, the cURL command is an alias of the Invoke-WebRequest cmdlet. The Invoke-WebRequest cmdlet is used to send requests to a website.
Thanks to dugas I learn how to execute streams with powershell, and with this link http://blog.commandlinekungfu.com/2009/11/episode-70-tangled-web.html I understand how to get content as a stream from http with powershell.
So the final curl | powershell pipe looks like this:
PS C:\>(New-Object System.Net.WebClient).DownloadString("http://url/script.ps1") | powershell -command -
Thanks a lot to everyone that contribute to this question :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With