curl http://url/script.ps1 | powershell possible? curl http://url/script.ps1 | powershell possible? powershell powershell

curl http://url/script.ps1 | powershell possible?


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 :-)


You can specify the command parameter of powershell with a hyphen to make it read its command from standard input. Below is an example:

"Write-Host This is a test" | powershell -command -

Example of using contents of a script file:

Get-Content .\test.ps1 | powershell -command -

From the powershell help menu:

powershell /?

-Command
Executes the specified commands (and any parameters) as though they were typed at the Windows PowerShell command prompt, and then exits, unless NoExit is specified. The value of Command can be "-", a string. or a script block.

If the value of Command is "-", the command text is read from standardinput.