1
00:00:01,140 --> 00:00:03,410
There's nothing special about running a command in

2
00:00:03,410 --> 00:00:07,140
PowerShell once you know what you want to run.

3
00:00:07,140 --> 00:00:10,140
Type the command at the PowerShell prompt and press Enter.

4
00:00:10,140 --> 00:00:13,540
I bet you can guess what this command's going to do based on the name.

5
00:00:13,540 --> 00:00:17,240
PowerShell runs the command and displays the results.

6
00:00:17,240 --> 00:00:21,840
Now in the Windows world, PowerShell commands are not case sensitive.

7
00:00:21,840 --> 00:00:23,710
I'll come back to this when I get to the demo,

8
00:00:23,710 --> 00:00:27,290
but I'm going to encourage you to take advantage of tab completion

9
00:00:27,290 --> 00:00:30,720
and other console tricks to quickly bring up the command or

10
00:00:30,720 --> 00:00:33,240
PowerShell expression that you want to run.

11
00:00:33,240 --> 00:00:37,420
PowerShell does not mean a lot of typing of you're smart about how you work.

12
00:00:37,420 --> 00:00:41,040
Many commands can be customized through parameters.

13
00:00:41,040 --> 00:00:44,210
These help you refine your command so that it does

14
00:00:44,210 --> 00:00:46,440
exactly what you need it to do.

15
00:00:46,440 --> 00:00:49,160
You should read the help for a command to learn about the

16
00:00:49,160 --> 00:00:51,700
different parameters and how they operate,

17
00:00:51,700 --> 00:00:55,040
but it's very easy to add them to your command.

18
00:00:55,040 --> 00:00:56,620
You can use tab completion.

19
00:00:56,620 --> 00:01:02,340
Start typing the parameter name like ‑dri, and press Tab.

20
00:01:02,340 --> 00:01:06,420
PowerShell will cycle through all parameters that begin with those letters.

21
00:01:06,420 --> 00:01:11,540
Now in some commands, you can also tab complete possible parameter values.

22
00:01:11,540 --> 00:01:14,370
Another option is to use keyboard shortcuts that are

23
00:01:14,370 --> 00:01:16,730
part of the PSReadline module.

24
00:01:16,730 --> 00:01:19,570
These commands come automatically installed in PowerShell.

25
00:01:19,570 --> 00:01:22,040
You'll see these when I get to the demo.

26
00:01:22,040 --> 00:01:25,060
A few quick words about PowerShell command parameters.

27
00:01:25,060 --> 00:01:29,390
These too follow a convention, which makes them easy to learn.

28
00:01:29,390 --> 00:01:33,150
All parameter names start with a dash, so in this example,

29
00:01:33,150 --> 00:01:37,240
you would type or tab complete ‑DriveLetter.

30
00:01:37,240 --> 00:01:40,740
After the parameter name, you press the space bar,

31
00:01:40,740 --> 00:01:42,720
then type the parameter value.

32
00:01:42,720 --> 00:01:45,680
Now as I mentioned just a moment ago, in some cases,

33
00:01:45,680 --> 00:01:48,210
you might even be able to tab complete the values.

34
00:01:48,210 --> 00:01:50,940
It really never hurts to try.

35
00:01:50,940 --> 00:01:54,500
There are also a few other parameter features that you might encounter.

36
00:01:54,500 --> 00:01:58,830
Now even though I told you about typing the parameter name,

37
00:01:58,830 --> 00:02:01,260
sometimes you don't even have to do that.

38
00:02:01,260 --> 00:02:03,420
So here's a great example.

39
00:02:03,420 --> 00:02:07,370
The Get‑Service command has a parameter called name.

40
00:02:07,370 --> 00:02:11,380
That lets you specify the names of the services that you want to see.

41
00:02:11,380 --> 00:02:12,300
However,

42
00:02:12,300 --> 00:02:15,700
you don't have to include the parameter name. If you

43
00:02:15,700 --> 00:02:20,460
type the command as I've done here, PowerShell will assume that the values,

44
00:02:20,460 --> 00:02:25,140
bits, winrm, and spooler, belong to the name parameter.

45
00:02:25,140 --> 00:02:30,050
The name parameter is called positional, or we refer to it as a positional.

46
00:02:30,050 --> 00:02:33,640
You don't have to type the parameter name.

47
00:02:33,640 --> 00:02:36,690
Some commands have mandatory parameters.

48
00:02:36,690 --> 00:02:41,840
These are parameters that at least require you to enter some value.

49
00:02:41,840 --> 00:02:45,880
These parameters are easy to identify because if you forget something,

50
00:02:45,880 --> 00:02:49,340
PowerShell will prompt you for the missing values.

51
00:02:49,340 --> 00:02:52,030
You'll also learn that many commands, like Get‑Service,

52
00:02:52,030 --> 00:02:55,940
have a default behavior so you don't really have to do anything.

53
00:02:55,940 --> 00:02:56,520
In fact,

54
00:02:56,520 --> 00:02:58,970
you should be able to run just about any command

55
00:02:58,970 --> 00:03:04,340
simply by typing the command name, especially if it is a get command.

56
00:03:04,340 --> 00:03:09,040
If there is a mandatory parameter, PowerShell will simply prompt you for a value.

57
00:03:09,040 --> 00:03:12,540
Otherwise, it will run the command with the default settings.

58
00:03:12,540 --> 00:03:15,600
By the way, if the parameter can take multiple values,

59
00:03:15,600 --> 00:03:20,110
like the names of services here, separate the values with commas.

60
00:03:20,110 --> 00:03:25,820
All PowerShell cmdlets and most functions have a set of common parameters.

61
00:03:25,820 --> 00:03:28,640
One such parameter is ‑Verbose.

62
00:03:28,640 --> 00:03:34,140
Now you can try to include it with any PowerShell command.

63
00:03:34,140 --> 00:03:37,390
If the verbose option has been coded into the command,

64
00:03:37,390 --> 00:03:40,040
you'll see extra information.

65
00:03:40,040 --> 00:03:43,840
This can be very helpful when troubleshooting why a command doesn't work.

66
00:03:43,840 --> 00:03:47,000
However, not every command takes advantage of this feature.

67
00:03:47,000 --> 00:03:49,840
You really won't know if it does until you try.

68
00:03:49,840 --> 00:03:53,340
Now you won't break anything, so just give it a shot.

69
00:03:53,340 --> 00:03:58,240
Another common parameter is ‑WhatIf. This parameter has a very special use

70
00:03:58,240 --> 00:04:04,780
case. You can see the result right here from using ‑WhatIf. When using ‑WhatIf,

71
00:04:04,780 --> 00:04:07,990
the command doesn't actually do anything. Instead,

72
00:04:07,990 --> 00:04:11,690
PowerShell shows you what it would have done if you ran the command

73
00:04:11,690 --> 00:04:16,540
without ‑WhatIf. So this is a great way to check yourself.

74
00:04:16,540 --> 00:04:19,870
This parameter is supposed to be used in any cmdlet that

75
00:04:19,870 --> 00:04:22,430
changes something, like starting a service,

76
00:04:22,430 --> 00:04:25,340
removing a file, or killing a process.

77
00:04:25,340 --> 00:04:27,390
Although you will encounter cmdlets that probably

78
00:04:27,390 --> 00:04:29,490
should support this parameter but don't.

79
00:04:29,490 --> 00:04:35,000
And in those situations, there's really nothing you can do about it other than be careful.

