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

2.2. Branching Instructions

Branching instructions bear that name, because they split program execution according to a conditional statement. Typically they specify several possible execution flows. At the time of execution, a statement is evaluated, and a code path is chosen according to the value returned from that statement. PowerShell offers two branching instructions: if/else that allows us to choose one of two code paths, and switch that selects and executes one of many alternatives.

2.2.1. Simple Branching: if/else

The simplest branching instruction in many mainstream programming languages is the if statement. It evaluates a conditional expression and executes one block of code if the result is true, another if false. The general form ...

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