Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Foreach Loop

$
0
0

Iam trying to input a list of machines to a foreach loop and the loop should process only one machine at a time.

Consider the below loop. Say the variable $machinenames has the Values:-

ComputerA
ComputerB
ComputerC
ComputerD

Here it appears like the $test is getting the entire list instead of each machine at a time.. Is there a de-limiter which we can specify some where or some one please suggest me a better way?

------------------------------------------------------------------------

$machinenames =Get-content "C:\Testfile.txt"

Foreach ($test in $machinenames)

{# do a task}

----------------------------------------------------====


Justin Abraham ----------------------------- Knowledge is Power



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>