I'm creating a script that will get a list of Cluster objects from Active Directory, iterate through them comparing the cluster node names to a name that is input earlier in the script and add the cluster that contains the matching node name to a PSObject. I'm accomplishing this with a nested ForEach loop and the break works great on the internal loop, but the break on the containing ForEach loop just stops the script entirely instead of breaking out of that loop and I'm not sure why. Would someone mind taking a look at my code block and seeing if they can see why that's happening? Thanks!
Question
Stokkolm
I'm creating a script that will get a list of Cluster objects from Active Directory, iterate through them comparing the cluster node names to a name that is input earlier in the script and add the cluster that contains the matching node name to a PSObject. I'm accomplishing this with a nested ForEach loop and the break works great on the internal loop, but the break on the containing ForEach loop just stops the script entirely instead of breaking out of that loop and I'm not sure why. Would someone mind taking a look at my code block and seeing if they can see why that's happening? Thanks!
Link to comment
https://www.neowin.net/forum/topic/1329964-powershell-break-loop-problem/Share on other sites
1 answer to this question
Recommended Posts