I have some predefined variables, eg:
$s1 = a
$s2 = b
...
$s[x] = x
I have a script that connects to a device via serial port, get some data, split the string and get a value I need. The value that I have from the string I needed to use it to get a predefined variable.
In php I do it easily like this:
$var1 = a
$var2 = b
...
$var[x] = x
$i = something
echo ${"var_name$i"}
How can I do the same in PowerShell? I tried
write-host $s$i
write-host $s{$i}
write-host ${s$i}
write-host ${"s$i"}
with no luck...all I get is either the value of $i
or empty space