1
00:00:01,240 --> 00:00:01,800
And with that,

2
00:00:01,800 --> 00:00:04,780
let's get back into PowerShell and let me demonstrate how

3
00:00:04,780 --> 00:00:07,380
you can discover what you can do with it.

4
00:00:07,380 --> 00:00:11,540
I often tell people that I don't train people in PowerShell, I teach them.

5
00:00:11,540 --> 00:00:14,980
Training implies that you have to learn a certain way to achieve a task.

6
00:00:14,980 --> 00:00:17,440
Click here, type that, press this button.

7
00:00:17,440 --> 00:00:18,950
PowerShell isn't like that.

8
00:00:18,950 --> 00:00:21,540
I need to teach you how PowerShell works and how you can

9
00:00:21,540 --> 00:00:25,290
continue to teach yourself so that you can continue to learn

10
00:00:25,290 --> 00:00:27,940
PowerShell long after our class is over.

11
00:00:27,940 --> 00:00:31,260
But enough of that, let's get into PowerShell. Alright,

12
00:00:31,260 --> 00:00:35,280
so back in PowerShell and I have a prompt open, and

13
00:00:35,280 --> 00:00:37,590
let's just look at this Get‑Command.

14
00:00:37,590 --> 00:00:41,000
Let's run Get‑Command, and if I hit Enter by itself,

15
00:00:41,000 --> 00:00:44,230
this is going to go through and find all of the commands

16
00:00:44,230 --> 00:00:47,240
that PowerShell knows about on my computer.

17
00:00:47,240 --> 00:00:51,420
Your list, obviously, will look different than what I might have here.

18
00:00:51,420 --> 00:00:53,020
Now I'm going to do something a little bit different here,

19
00:00:53,020 --> 00:00:55,310
I'm going to do Get‑Command, and the thing I'm going to

20
00:00:55,310 --> 00:00:57,680
look for is a vegetable object.

21
00:00:57,680 --> 00:00:59,550
This is just kind of a placeholder,

22
00:00:59,550 --> 00:01:03,100
something I've built for myself for teaching so that you don't get bogged down

23
00:01:03,100 --> 00:01:06,340
on technical details, you can just focus on the concepts.

24
00:01:06,340 --> 00:01:10,740
So I've told PowerShell, hey, I need to do something with vegetables.

25
00:01:10,740 --> 00:01:14,480
What commands do you know about so I can do Get‑Command and then some

26
00:01:14,480 --> 00:01:18,590
wildcard around the thing that I want, vegetable So I can see that

27
00:01:18,590 --> 00:01:21,700
PowerShell knows about commands such as Get‑Vegetable,

28
00:01:21,700 --> 00:01:24,480
New‑Vegetable or Set‑Vegetable. Notice they follow

29
00:01:24,480 --> 00:01:27,540
that Verb‑Noun naming convention.

30
00:01:27,540 --> 00:01:29,910
So once you understand how that pattern works,

31
00:01:29,910 --> 00:01:33,940
then we can try it with real commands, like say services.

32
00:01:33,940 --> 00:01:39,910
I did a wildcard around *service*, so I get a lot of things. And maybe I

33
00:01:39,910 --> 00:01:44,640
want to refine that. So let's do Get‑Command *service,

34
00:01:44,640 --> 00:01:48,610
no wildcard at the end of that, now I get a much more manageable

35
00:01:48,610 --> 00:01:52,380
list. This is probably really what I was looking for.

36
00:01:52,380 --> 00:01:56,080
Get‑Command also has this option to work with verbs, so say hey,

37
00:01:56,080 --> 00:02:01,160
tell me everything that you know about that I can get. Again, it's going to be a

38
00:02:01,160 --> 00:02:06,240
pretty long list. Now how did I know Get was a verb other than seeing it there

39
00:02:06,240 --> 00:02:09,560
in the list? Well, there is the command Get‑Verb,

40
00:02:09,560 --> 00:02:11,540
which I mentioned to you before,

41
00:02:11,540 --> 00:02:15,360
and this will show you all of the possible verbs that

42
00:02:15,360 --> 00:02:17,930
you can find in a PowerShell command.

43
00:02:17,930 --> 00:02:19,290
When you get to scripting,

44
00:02:19,290 --> 00:02:22,740
you'll be using these same verbs for your own commands.

45
00:02:22,740 --> 00:02:24,530
So once you see what those verbs are,

46
00:02:24,530 --> 00:02:28,400
then it becomes easier to discover what it is that you can do.

47
00:02:28,400 --> 00:02:31,490
So I know one of the verbs is Stop, so let's do

48
00:02:31,490 --> 00:02:35,540
Get‑Command and look for all the Stop commands.

49
00:02:35,540 --> 00:02:40,300
There we go, really, you know, quite a few. Nouns work kind of the same way.

50
00:02:40,300 --> 00:02:42,220
Let's go back to my vegetable idea.

51
00:02:42,220 --> 00:02:47,120
Let's say I don't know the full name of the thing that's a

52
00:02:47,120 --> 00:02:50,020
vegetable, maybe it's vegetable foo or something else, so

53
00:02:50,020 --> 00:02:51,490
I'll just use the wildcard.

54
00:02:51,490 --> 00:02:56,140
So we'll do veg*, and then I get my commands.

55
00:02:56,140 --> 00:03:00,460
Once we know the pattern, now we can do it with real things such as,

56
00:03:00,460 --> 00:03:04,740
say, processes, or something with process in the name.

57
00:03:04,740 --> 00:03:08,940
And again, we may want to fine tune that list.

58
00:03:08,940 --> 00:03:10,120
As I said in the slides,

59
00:03:10,120 --> 00:03:16,170
we can also combine these things and I can combine the noun and the verb to say

60
00:03:16,170 --> 00:03:22,280
find me all of the commands that start with re, like remove,

61
00:03:22,280 --> 00:03:28,870
replace, or whatever, and then share is some part of the noun. And there we go.

62
00:03:28,870 --> 00:03:37,000
So now I have found some other commands that I can work with that meet the criteria that I was looking for.

