Iterate Through Your Data
Filtering a collection of objects and outputting them to the screen is useful for simple reporting, but oftentimes, what you really want to do is iterate over the collection and perform some sort of task. Windows PowerShell provides six different ways that we can iterate through our collections; five of them are built-in constructs (like the if/elseif/else construct) and one is a special cmdlet. This section will detail each of the techniques and why you would use them.
Use While Loops
A while loop allows you to perform a given task while a condition remains true. In a while loop, the code to execute may never be hit if the condition on which to execute the code evaluates to $false on the first run. The syntax for a ...
Get Automating Microsoft® SharePoint® 2010 Administration with Windows PowerShell® 2.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.