Chapter 6. Flow control in scripts

6.1

Using the if/elseif/else statement

148

6.2

The while loop

151

6.3

The do/while loop

152

6.4

The for loop

153

6.5

The foreach loop

155

6.6

Labels, break, and continue

159

6.7

The PowerShell switch statement

161

6.8

Flow control using cmdlets

169

6.9

The value of statements

175

6.10

Summary

176

 

I may not have gone where I intended to go, but I think I have ended up where I needed to be.

 
 --Douglas Adams, The Long Dark Teatime of the Soul

Previous chapters showed you how to solve remarkably complex problems in PowerShell using only commands and operators. You can select, sort, edit, and present all manner of data by composing these elements into pipelines and expressions. In fact, commands and operators were the only elements available in ...

Get Windows PowerShell in Action 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.