I am a beginner in Powershell and I am seeking help on completing a task.
I have two lists namely:
$name = "a,b,c"
$number = "1,2,3"
I want to print a value from list1 and list2 together in the below format:
{ name = "a", number = "1" }, { name = "b", number = "2" }, { name = "c", number = "3" }
I have tried the below code but I am not achieving the desired result:
Clear-Host
$list1 = "a,b,c"
$list2 = "1,2,3"
foreach ($i in $list1)
{
$temp1 = $list1 -split ","
foreach ($j in $list2)
{
$temp2 = $list2 -split ","
}
$output = "{ value1 = ""$i"", value2 = ""$j"" }"
echo $output
}
I get the below output after executing the code:
{ name = "a,b,c", number = "1,2,3" }