A script fills several variables with various numbers and names with numbers (strings).
$mPS01
$mPS02
$mPS03
$mPS04
$mPS05
$sName_01
$sName_02
$sName_03
$sName_04
$sName_05
The command
Write-Host 'Var mPS01:' $mPS01 / $sName_01
perfectly outputs the content of this variable pair.
Question: How can those variables be displayed using a for-loop? (The number of numbered variables is known.)
Below is the code I started with, but I cannot get it to output the contents of the variables.
for($i = 1; $i -lt 6; $i++) { write-Host mPS0$i":" $mPS0$i / $sName_0$i }
The output is numbered according to the value of $i
instead of the variables corresponding contents.
mPS01: 1 / 1
mPS02: 2 / 2
mPS03: 3 / 3
mPS04: 4 / 4
mPS05: 5 / 5
I'd think there is some trick for proper formatting to achieve the desired output of the content, but I could not find a solution.