O'Reilly logo

Windows PowerShell in Action, Third Edition by Bruce Payette Richard Siddaway

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

Chapter 5. Flow control in scripts

This chapter covers

  • Conditional, looping, and switch statements
  • Labels, break, and continue
  • Flow control with cmdlets
  • Statements as values
  • Performance issues

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 Tea-Time of the Soul

Previous chapters showed how you can solve surprisingly complex problems in PowerShell using only commands and operators. Sooner or later, though, if you want to write significant programs or scripts, you must add custom looping or branch logic to your solution. Conditional statements enable your code to branch, dependent on tests you create. Loops execute a block of code one or more times depending on ...

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