Answer the question
In order to leave comments, you need to log in
How to correctly read an array in a Powershell loop?
Good day everyone!
There are arrays:
$target1 = ("D:\1", "D:\2","D:\3")
$target2 = ("C:\1", "C:\2", "C:\3")
$target3 = ($target1,$target2)
foreach($foreachTarget in $target3)
{
$src = $foreachTarget[1]
$xdt = $foreachTarget[0]
ECHO $src $xdt
}
D:\2 D:\1
C:\2 C:\1
D:\1 C:\1
D:\2 С:\2
D:\3 С:\3
Answer the question
In order to leave comments, you need to log in
# example from https://stackoverflow.com/questions/43122000/how-c...
#
$func = { param ($a, $b) ('{0} {1}' -f $a , $b)}
[Linq.Enumerable]::Zip(@("D:\1", "D:\2","D:\3"), @("C:\1", "C:\2", "C:\3"), [Func[Object, Object, Object[]]]$func)
D:\1 C:\1
D:\2 C:\2
D:\3 C:\3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question