O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

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

5.3. Functions and Script Blocks

Combining functions and script blocks results in some very powerful programming techniques. By combining functions' ability to create new commands with the dynamic nature of script blocks, we can get very close to the built-in PowerShell language syntax. Calling a function that accepts a single script block closely resembles using the if, while, or switch statements. That makes our code look as if it builds and uses new language constructs that makes it easier to read and understand. In addition to the cool syntax, script blocks make a perfect tool for encapsulating actions or strategies that can be executed by a function as it traverses various objects.

5.3.1. Implementing New Control Structures

I do not remember ...

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