I need to run the code below on about 200 client machines. The code works as I intended, but I'm wondering if there is a more efficient way to do this without using nested ForEach loops? Nesting loops just doesn't seem efficient to me.
In my use case scenario, is it safe to say the performance difference in all those options are probably negligible at best? I know I can use Measure-Command, but how accurate a measure of performance is that?
Would also work just fine. Invoke-Command is going to be a lot faster than using a foreach loop with 200 computers. Invoke-Command takes an array of strings also so you can simply just give it every machine name at the same time. Give it a shot. Let us know how you go.