1
00:00:01,040 --> 00:00:03,460
Next, let's look at aliases.

2
00:00:03,460 --> 00:00:04,540
Now in PowerShell,

3
00:00:04,540 --> 00:00:09,500
you know that you can run the dir command to get a listing of files and folders.

4
00:00:09,500 --> 00:00:11,070
If you're a Linux‑type person,

5
00:00:11,070 --> 00:00:16,520
obviously you know you can also use the ls command. Works the same way.

6
00:00:16,520 --> 00:00:18,710
Now what you're really though running is a

7
00:00:18,710 --> 00:00:22,440
PowerShell command called get‑childitem.

8
00:00:22,440 --> 00:00:25,940
The ls and dir commands are just aliases.

9
00:00:25,940 --> 00:00:28,710
PowerShell commands also have a lot of aliases.

10
00:00:28,710 --> 00:00:29,170
For example,

11
00:00:29,170 --> 00:00:33,990
you may see code out there that uses what looks like a cryptic command,

12
00:00:33,990 --> 00:00:38,440
gsv, but that's really just running Get‑Service.

13
00:00:38,440 --> 00:00:41,640
The full command is Get‑Service.

14
00:00:41,640 --> 00:00:46,170
Now, how did I know that Get‑Service and gsv are the same thing?

15
00:00:46,170 --> 00:00:47,780
Well, you can use Get‑Command.

16
00:00:47,780 --> 00:00:52,840
So if you see an alias like gsv, Get‑Command, the name of the alias.

17
00:00:52,840 --> 00:00:56,400
It's clear, with that little representation of the arrow,

18
00:00:56,400 --> 00:01:01,440
that gsv is resolving to Get‑Service.

19
00:01:01,440 --> 00:01:03,830
And so if I then did Get‑Command Get‑Service,

20
00:01:03,830 --> 00:01:05,610
I could see, oh, yep, it's a command,

21
00:01:05,610 --> 00:01:10,240
and I see what version I'm running and the source of that.

22
00:01:10,240 --> 00:01:12,890
Obviously, taking this to the next step then is to run Help

23
00:01:12,890 --> 00:01:16,510
on Get‑Service so I can see how to use it.

24
00:01:16,510 --> 00:01:19,750
And then you use the same parameters with the alias.

25
00:01:19,750 --> 00:01:22,840
The alias is just an alternate name,

26
00:01:22,840 --> 00:01:26,000
just like a criminal alias, also known as gsv.

27
00:01:26,000 --> 00:01:30,520
Run gsv ‑Name, ‑DependentServices,

28
00:01:30,520 --> 00:01:34,840
‑DisplayName the same way you would use it with Get‑Service.

29
00:01:34,840 --> 00:01:38,550
In fact, you can also do help on the alias, and it will resolve.

30
00:01:38,550 --> 00:01:41,400
So if I want to say, hey, how do I use the dir command,

31
00:01:41,400 --> 00:01:47,850
such as it is in PowerShell, help dir will resolve to Get‑ChildItem,

32
00:01:47,850 --> 00:01:49,830
and then all those parameters,

33
00:01:49,830 --> 00:01:52,900
you can use them the same way that you would with Get‑ChildItem.

34
00:01:52,900 --> 00:02:01,140
You can use it with the alias of dir or ls.

35
00:02:01,140 --> 00:02:05,160
And if I want to find out what commands I can use with aliases,

36
00:02:05,160 --> 00:02:10,420
hey, sure enough, ask PowerShell, what commands do you know with the alias noun?

37
00:02:10,420 --> 00:02:11,980
And there are a number of them,

38
00:02:11,980 --> 00:02:19,000
and I'll let you play with the help and see how to work with those and create your own aliases.

