I am trying to read the values from file abc.txt in below function
abc.txt
a=abcdef123
b=ngh567
c=defh123
Below is the function:
function List
{
Write-Output "Below are the window boxes"
$alph = @(get-content -Path "abc.txt" | %{$_.split('=')[0]})
$machinelist = @(get-content -Path "abc.txt" | %{$_.split('=')[1]})
$counter = 0
foreach ($mac in $machinelist) {
foreach ($env in $alph ) {
{
$counter++
write-host ""$counter": Press '"$counter"' to select "$env": $mac"
}
}
}
I want the input similar to
1: Press '1' to select a : abcdef123
2: Press '2' to select b : ngh567
3: Press '3' to select c : defh123
Please make a selection:
I think we need to use nested foreach but not sure what am I doing wrong Once I make the selection for e.g. 1 then I want read the value like env and mac