The downside of that method is that it will evaluate all the items in the data block. If the data block is relatively small, it's not a big deal. Otherwise, I'd probably be looking at a different search mechanism.
-----Original Message----- From: Joseph L. Casale [mailto:[email protected]] Sent: Tuesday, May 29, 2012 12:30 PM To: NT System Admin Issues Subject: RE: Classic break/continue issue in foreach loop >I have a collection of collections I need to iterate over: $_.Data |%{ >Match, then break } > >Problem is return/continue do not end the final iteration of objects, >how does one effectively accomplish this? $_.Data is actually a >collection itself from a larger collection? Once I match, there is no >point in continuing to look, but the scope of break still appears global so >the script halts? I rectified this with a Where-Object and 'Select -First 1' $_.Data |?{ $_."#text" -iMatch $Filter } | Select -First 1 |Out-Null <Increment totals...> Not so sure this the best way, but it works... jlc ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
