Making Decisions

Now that we have mastered the process of looping through code, it is time to add some intelligence to our code. There are two statements we can use in our code to add intelligence. The first of the statements is the easiest to use and is the one that makes sense to most people: if … elseif … else . The reason it is so easy to use is that it is intuitive. We are used to saying things like: "If it is sunny this afternoon, then I will go surfing. In Windows PowerShell, the then clause is understood and not specifically used, but the syntax is still very intuitive.

The second decision-making statement is one that at first glance does not make sense: the switch statement. The switch statement is the Windows PowerShell equivalent to ...

Get Microsoft® Windows PowerShell™ Step By Step now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.