Automation is perhaps only half-complete without loops. After all, the point of automation in most situations is making the computer do what is repetitive. There are six looping constructs in PowerShell in all:
- Looping using Foreach-Object
- The Foreach loop
- The For loop
- The While loop
- The Do–While loop
- The Do-Until loop
The Foreach-Object looping construct is perhaps the simplest of them all.
Let's imagine that we have a list of five guests to a certain event, and you would like to greet them each individually.