Home > Mobile >  Is it possible to pass a variable into a piped powershell script?
Is it possible to pass a variable into a piped powershell script?

Time:01-19

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?

CodePudding user response:

It can't be done with Invoke-Expression, however you can do it by converting the expression into a iex

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

& ([scriptblock]::Create((irm get.scoop.sh))) -ScoopDir C:\foo\bar
  • Related