I'm trying to create a script that loops through a list of names and updates 2 text files with information from the loop.
It isnt working at all though.
Here is my script:
$TestFile1 = "C:\Powershell\TestFile1.txt"
$TestFile2 = "C:\Powershell\TestFile2.txt"
$i = 0
$TestFiles = @() $TestFiles = @($TestFile1, $TestFile2)
$names = ("adam", "kumiko", "dave", "liam")
foreach ($name in $names)
$name + "Hello1" | out-file $TestFiles[$i]
$name + "Hello2" | out-file $TestFiles[$i]
$name + "Hello3" | out-file $TestFiles[$i]
I really have a hard time understanding the logic behind having a loop and then inside the loop, iterating through an array.
Any help would be really great.