0

I looking for this in powershell

$VAR0=args[0]
$VAR1=args[1]
$VAR2=args[2]

With a construction like this

$a=0
$VAR+$a=args[$a]

but I cannot concatenate this way

4
  • $VAR0,$VAR1,$VAR2 = $args[0], $args[1], $args[2], this what you mean? Commented Apr 11, 2022 at 13:46
  • nope, in $VAR0 I need 0 as a variable; like $a=0 $VAR+$a= args[$a] Commented Apr 11, 2022 at 13:49
  • doing what you describe is a well known BIG FAT ERROR. [grin] don't do that - you already have it all in a nice, solid, easy-to-use $Var ... the $Args collection ... so use it instead of making your code more complex for no reason at all. Commented Apr 11, 2022 at 14:02
  • What you're looking for is variable indirection, where you refer to a variable indirectly, via its name stored in a different variable or provided by an expression. PowerShell enables this via the Get-Variable and Set-Variable cmdlets, but note that there are usually better alternatives. See the linked duplicate for details. Commented Apr 11, 2022 at 14:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.