
When working with PowerShell and objects such as User in Entra ID or mailboxes in Exchange Online, you might quickly run into scenarios where you might want to repeat a set of instructions for multiple objects. This can happen for example, when configuring mailbox properties for multiple mailboxes. This construct of flow control is called looping.
In the third installment of the Practical PowerShell series, I discuss which types of looping are available in PowerShell and what their typical application is. Topics discussed are For loops, ForEach-Object vs ForEach, and While/Do-While and Do-Until. On the side, I will also touch briefly on casting, the format operator, and running code in parallel using ForEach-Object.