First I have tried to locate other questions and these all seem related to replacement rather than expansion.
- How to expand variable in powershell?
- Powershell variable expansion when calling other programs
- Powershell variable expansion in parameters
- How to expand a variable when calling another powershell instance?
So I must first create clarity on what I mean by "expansion".
> $TEST="Foo Bar"
> echo foo bar
foo
bar
> echo $TEST
Foo Bar
When passing two parameters, powershell's implementation of echo will print each parameter on its own line.
If I echo a variable with two parameters it is passed as a single parameter. I would like the variable to be expanded into the multiple arguments which it contains, getting the behavior from the first instance.
I have looked at:
- Single quotes
- Parentheses
- Curly braces in different forms
Is this possible in powershell?
Context Update:
Unfortunately I'm not the one setting the variable, this comes from gitlab environment variables.
echo (-split $TEST)
maybe? Another way:echo $TEST.split()
– Spinelli"Foo Bar"
. Try$TEST = "Foo", "Bar"
in comparison – Boozeecho foo bar
is an alias forWrite-Output @("foo", "bar")
- i.e. write out an array containing two strings, whereasecho $TEST
is basicallyWrite-Output "Foo Bar"
- i.e. output a single string. If you do what @Mathias R. Jessen says you're setting the variable$TEST
to be an array of 2 strings so it'll output them on separate lines. – Hive