O'Reilly logo

Automating Microsoft® SharePoint® 2010 Administration with Windows PowerShell® 2.0 by Shannon Bray, Gary Lapointe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required