3

I'm basing a small project off of the below one-liner, but I'm struggling to pass parameters into it on the same line.

irm get.scoop.sh | iex

This script can take additional parameters, such as -ScoopDir.

How does one pass -ScoopDir C:\foo\bar into the one-liner?

2
  • 1
    & ([scriptblock]::Create((irm get.scoop.sh))) -ScoopDir C:\foo\bar Commented Jan 19, 2023 at 4:37
  • 1
    Glorious. Want to post it as the answer? Commented Jan 19, 2023 at 4:54

1 Answer 1

2

It can't be done with Invoke-Expression, however you can do it by converting the expression into a script block first then you can pass arguments as if it was a function.

Do note:

iex

This still applies for the [scriptblock]::Create(...) approach.

& ([scriptblock]::Create((irm get.scoop.sh))) -ScoopDir C:\foo\bar
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Does exactly as described!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.