Next, let's take a quick look at the math operator.
The math operators in PowerShell are the same ones
you've used probably your entire life.
So the plus symbol.
So 5+8, and PowerShell will give you the result obviously of 13.
Division is the slash. Multiplication is the asterisk.
So 2*3*4 gives me the result of 24.
Subtraction obviously is the minus sign. And you can use the parentheses
to control precedence for more complex expressions.
Now we also have an operator called the range operator.
That is the dot dot.
So this will give me all of the numbers or values
between a starting and ending point.
So PowerShell will give me the numbers 1 through 5.
It's a really handy way of getting a range of
numbers for some particular operation.
You can go in reverse even, so 10..7 will give me the
numbers 10 through 7 going in reverse order.
Here's a way, and this is technically two ranges,
and here I'm using parentheses.
So the first element in this expression is 1 through 4 using the range operator.
And I have that in parentheses, so that tells PowerShell, hey,
run this little snippet, or this block of code, inside the
parentheses, comma, and then also display 7 through 10.
So I get the numbers 1, 2, 3, 4 and 7, 8, 9,10.
However, the range operator does not work with letters.
It only works for numbers. Although, here's a little trick, and it's kind of
an advanced hack, if you will. All characters that you type on your keyboard
actually are represented by a .NET class called Char, C‑h‑a‑r, and you see
that in square brackets. So I can take a number and tell PowerShell, hey,
treat this as its character object.
And so the lowercase a actually has a numeric value of 97, so
get all the numbers between 97 and 105,
and for each one, display it to me as a Char object.
And so I can see I get the letters a, b, c, d, e, f, g, h, i.
And so just as a point of reference,
the letters A through Z capitalized are 65 through 90, so
you can kind of try this out on your own. Again, this is
kind of an advanced topic,
but I wanted to give you an indication of other ways that you might want to use the range operator.