2

Following PsGet example, this is how I run a ps1 from an url:

(new-object Net.WebClient).DownloadString($Url) | iex

Now, it would be great if I could pass parameters to that script in a one liner like this, but any parameters I pass go to iex instead of getting passed to the script.

How can it be done in a one line? Perhaps it can have two chained commands, but three commands is already too much for a one line.

1 Answer 1

6

You could create an unnamed scriptblock from the string and then invoke it using the call operator (&):

& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString($Url))) -param1 argumentvalue
Sign up to request clarification or add additional context in comments.

1 Comment

that is cool thanks! btw, wouldn't it work with iex, why &?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.