1
00:00:01,140 --> 00:00:04,340
Next, let's take a quick look at the math operator.

2
00:00:04,340 --> 00:00:06,550
The math operators in PowerShell are the same ones

3
00:00:06,550 --> 00:00:08,800
you've used probably your entire life.

4
00:00:08,800 --> 00:00:10,070
So the plus symbol.

5
00:00:10,070 --> 00:00:13,860
So 5+8, and PowerShell will give you the result obviously of 13.

6
00:00:13,860 --> 00:00:18,480
Division is the slash. Multiplication is the asterisk.

7
00:00:18,480 --> 00:00:22,840
So 2*3*4 gives me the result of 24.

8
00:00:22,840 --> 00:00:27,810
Subtraction obviously is the minus sign. And you can use the parentheses

9
00:00:27,810 --> 00:00:31,740
to control precedence for more complex expressions.

10
00:00:31,740 --> 00:00:34,880
Now we also have an operator called the range operator.

11
00:00:34,880 --> 00:00:36,330
That is the dot dot.

12
00:00:36,330 --> 00:00:40,140
So this will give me all of the numbers or values

13
00:00:40,140 --> 00:00:43,000
between a starting and ending point.

14
00:00:43,000 --> 00:00:46,710
So PowerShell will give me the numbers 1 through 5.

15
00:00:46,710 --> 00:00:49,460
It's a really handy way of getting a range of

16
00:00:49,460 --> 00:00:52,640
numbers for some particular operation.

17
00:00:52,640 --> 00:00:56,280
You can go in reverse even, so 10..7 will give me the

18
00:00:56,280 --> 00:00:59,690
numbers 10 through 7 going in reverse order.

19
00:00:59,690 --> 00:01:02,210
Here's a way, and this is technically two ranges,

20
00:01:02,210 --> 00:01:03,690
and here I'm using parentheses.

21
00:01:03,690 --> 00:01:09,840
So the first element in this expression is 1 through 4 using the range operator.

22
00:01:09,840 --> 00:01:12,410
And I have that in parentheses, so that tells PowerShell, hey,

23
00:01:12,410 --> 00:01:16,370
run this little snippet, or this block of code, inside the

24
00:01:16,370 --> 00:01:20,960
parentheses, comma, and then also display 7 through 10.

25
00:01:20,960 --> 00:01:24,190
So I get the numbers 1, 2, 3, 4 and 7, 8, 9,10.

26
00:01:24,190 --> 00:01:28,400
However, the range operator does not work with letters.

27
00:01:28,400 --> 00:01:31,860
It only works for numbers. Although, here's a little trick, and it's kind of

28
00:01:31,860 --> 00:01:36,140
an advanced hack, if you will. All characters that you type on your keyboard

29
00:01:36,140 --> 00:01:41,060
actually are represented by a .NET class called Char, C‑h‑a‑r, and you see

30
00:01:41,060 --> 00:01:45,950
that in square brackets. So I can take a number and tell PowerShell, hey,

31
00:01:45,950 --> 00:01:49,040
treat this as its character object.

32
00:01:49,040 --> 00:01:54,280
And so the lowercase a actually has a numeric value of 97, so

33
00:01:54,280 --> 00:01:57,480
get all the numbers between 97 and 105,

34
00:01:57,480 --> 00:02:02,210
and for each one, display it to me as a Char object.

35
00:02:02,210 --> 00:02:07,340
And so I can see I get the letters a, b, c, d, e, f, g, h, i.

36
00:02:07,340 --> 00:02:09,260
And so just as a point of reference,

37
00:02:09,260 --> 00:02:14,400
the letters A through Z capitalized are 65 through 90, so

38
00:02:14,400 --> 00:02:17,160
you can kind of try this out on your own. Again, this is

39
00:02:17,160 --> 00:02:18,280
kind of an advanced topic,

40
00:02:18,280 --> 00:02:25,000
but I wanted to give you an indication of other ways that you might want to use the range operator.

