Now that we have all this state to work with, it's time to start making some decisions. We have already touched on how to make tests and comparisons in Chapter 1, and we'll be using the same operators here. In this section, we'll explore the
switch statements and see how they can be used, depending on certain conditions, to execute different parts of a script.
Starting with some simple cases, let's make comparisons between two constants. This will lay the foundation for what is to come:
7 -gt 5True MSH D:\MshScripts>
7 -eq 5False MSH D:\MshScripts>
"alpha" -lt "zulu"True
No surprises here. MSH is performing the comparison and putting a Boolean (true/false) value into the pipeline based on the outcome. Tests become more interesting when we compare a dynamic value against a constant one, but, in every case, a test will always generate a true/false value. ...