1
00:00:06,540 --> 00:00:08,250
- [Instructor] In this
segment, we're going to talk

2
00:00:08,250 --> 00:00:10,496
about and look at PowerShell.

3
00:00:10,496 --> 00:00:13,500
Now, PowerShell is a
powerful, no pun intended,

4
00:00:13,500 --> 00:00:17,040
task automation and configuration
management framework

5
00:00:17,040 --> 00:00:20,580
consisting of a command line
shell and scripting language.

6
00:00:20,580 --> 00:00:23,550
And it's straightforward
and easy to learn.

7
00:00:23,550 --> 00:00:25,620
Now, the quickest way to find PowerShell

8
00:00:25,620 --> 00:00:28,710
on a Windows device is to
go right to the search bar

9
00:00:28,710 --> 00:00:32,160
and type PowerShell, and
it will bring up the app.

10
00:00:32,160 --> 00:00:34,020
It's gonna give me an option of running

11
00:00:34,020 --> 00:00:37,290
as a currently logged in
user or as the administrator.

12
00:00:37,290 --> 00:00:39,660
I'm gonna choose to run
as the administrator.

13
00:00:39,660 --> 00:00:41,130
If I go down to my task bar,

14
00:00:41,130 --> 00:00:44,505
I'm gonna see the icon to open it up.

15
00:00:44,505 --> 00:00:45,930
That's going to bring me

16
00:00:45,930 --> 00:00:49,140
to the Windows PowerShell
shell, if you will.

17
00:00:49,140 --> 00:00:51,210
Tells me I'm running as an administrator

18
00:00:51,210 --> 00:00:53,313
and I'm right here at the prompt.

19
00:00:54,270 --> 00:00:56,130
Now, compiled commands and PowerShell

20
00:00:56,130 --> 00:00:57,900
are called commandlets.

21
00:00:57,900 --> 00:00:59,333
Commandlet names have the form

22
00:00:59,333 --> 00:01:02,700
of the singular verb dash noun command

23
00:01:02,700 --> 00:01:06,240
to make them really easy to
discover and to remember.

24
00:01:06,240 --> 00:01:08,400
So I wanna give you just some examples

25
00:01:08,400 --> 00:01:10,620
of how we interact with PowerShell.

26
00:01:10,620 --> 00:01:13,320
Some really simple examples to begin with.

27
00:01:13,320 --> 00:01:16,200
Let's say I wanna learn
what processes are running.

28
00:01:16,200 --> 00:01:19,080
Remember, I'm gonna
use the form verb noun.

29
00:01:19,080 --> 00:01:20,700
So the verb is get

30
00:01:20,700 --> 00:01:23,940
and the noun is gonna
be process, get process,

31
00:01:23,940 --> 00:01:24,990
and that's gonna come back

32
00:01:24,990 --> 00:01:27,150
and show me all the
processes that are running

33
00:01:27,150 --> 00:01:28,560
on this system.

34
00:01:28,560 --> 00:01:30,120
Maybe I wanna know what services.

35
00:01:30,120 --> 00:01:32,160
Again, verb dash noun.

36
00:01:32,160 --> 00:01:34,593
So get-service.

37
00:01:35,790 --> 00:01:38,280
There are all my running services.

38
00:01:38,280 --> 00:01:41,460
Well, I probably have a lot to
learn about using PowerShell

39
00:01:41,460 --> 00:01:43,500
so I really wanna become familiar

40
00:01:43,500 --> 00:01:45,360
with the help functionality.

41
00:01:45,360 --> 00:01:47,040
So if I wanna learn about help,

42
00:01:47,040 --> 00:01:48,780
what do you think it's gonna be?

43
00:01:48,780 --> 00:01:52,350
Well, let's start with the
verb get and then help.

44
00:01:52,350 --> 00:01:54,480
And that's gonna bring up information

45
00:01:54,480 --> 00:01:58,530
for me about how to use
help within the PowerShell.

46
00:01:58,530 --> 00:02:01,440
So the entire PowerShell help system

47
00:02:01,440 --> 00:02:04,770
I'm gonna just use cls
to clear the screen.

48
00:02:04,770 --> 00:02:08,760
Maybe I wanna get help
about how I interact

49
00:02:08,760 --> 00:02:11,790
with commands that have
the word "service" in it.

50
00:02:11,790 --> 00:02:16,710
Well get-help and then service.

51
00:02:16,710 --> 00:02:17,880
And that's gonna come back

52
00:02:17,880 --> 00:02:21,660
and tell me about all of
the commandlets or functions

53
00:02:21,660 --> 00:02:24,240
that are associated with the term service.

54
00:02:24,240 --> 00:02:26,250
And it will give me a synopsis.

55
00:02:26,250 --> 00:02:28,890
If I wanna learn more
about a particular one,

56
00:02:28,890 --> 00:02:29,850
let's say the first one,

57
00:02:29,850 --> 00:02:33,423
the list, get-service, well, get-help.

58
00:02:34,860 --> 00:02:37,170
And then what do you think comes next?

59
00:02:37,170 --> 00:02:39,063
Well, get-service.

60
00:02:40,200 --> 00:02:42,480
And that's going to give me specifics

61
00:02:42,480 --> 00:02:44,970
about how to use that
command, the synopsis,

62
00:02:44,970 --> 00:02:49,893
the syntax, description, related
links, and other remarks.

63
00:02:51,780 --> 00:02:54,510
Now there are an awful lot of commands

64
00:02:54,510 --> 00:02:55,950
that are at your fingertips.

65
00:02:55,950 --> 00:02:59,070
Well, really, we should call
them commandlets and functions.

66
00:02:59,070 --> 00:03:00,870
So how do you find out what they are?

67
00:03:00,870 --> 00:03:02,280
Well, you know what?

68
00:03:02,280 --> 00:03:04,200
There's a commandlet for that.

69
00:03:04,200 --> 00:03:06,603
It's gonna be get-command.

70
00:03:07,590 --> 00:03:09,570
And what we see here is a list

71
00:03:09,570 --> 00:03:12,180
of all of the commands and
functions that are available

72
00:03:12,180 --> 00:03:14,880
to us to use within PowerShell

73
00:03:14,880 --> 00:03:19,260
and obviously, it's a really,
really extensive list.

74
00:03:19,260 --> 00:03:21,270
So I'm just gonna stop this list.

75
00:03:21,270 --> 00:03:23,910
I'm gonna hit Control +
C, so we can continue on

76
00:03:23,910 --> 00:03:26,943
and I'll do cls again,
just to clear the screen.

77
00:03:27,870 --> 00:03:28,800
So let's do more

78
00:03:28,800 --> 00:03:31,860
than just run a list of
processes or services.

79
00:03:31,860 --> 00:03:33,870
Let's actually invoke some commands.

80
00:03:33,870 --> 00:03:35,940
So the first one I wanna show you

81
00:03:35,940 --> 00:03:39,700
and I'm gonna invoke-command,
is that I wanna go out

82
00:03:40,740 --> 00:03:43,890
out to the event log, my system event log,

83
00:03:43,890 --> 00:03:47,070
and I wanna have displayed
the last 50 entries,

84
00:03:47,070 --> 00:03:49,020
meaning the newest 50 entries.

85
00:03:49,020 --> 00:03:51,420
So I'm gonna say invoke-command.

86
00:03:51,420 --> 00:03:55,533
And the command I'm gonna
invoke is ScriptBlock.

87
00:03:59,651 --> 00:04:03,203
And then I'm gonna put in
some parameters, get-EventLog.

88
00:04:06,390 --> 00:04:09,120
And the one I wanna get is system.

89
00:04:09,120 --> 00:04:12,360
And I wanna get the newest 50 entries.

90
00:04:12,360 --> 00:04:16,353
So I'm gonna say newest 50
and close up those parameters.

91
00:04:17,520 --> 00:04:18,420
And there we go.

92
00:04:18,420 --> 00:04:22,473
That's the newest 50 entries
in my event system log.

93
00:04:23,460 --> 00:04:25,830
Now I can query almost anything

94
00:04:25,830 --> 00:04:27,480
with PowerShell on my local system

95
00:04:27,480 --> 00:04:30,000
as well as other systems I'm connected to

96
00:04:30,000 --> 00:04:32,615
as long as I have the appropriate rights.

97
00:04:32,615 --> 00:04:34,950
But I can also go outside my network.

98
00:04:34,950 --> 00:04:37,470
I can go out to the web and query the web.

99
00:04:37,470 --> 00:04:39,510
I'm gonna do another invoke command.

100
00:04:39,510 --> 00:04:42,630
This time, I'm gonna go
out to a Microsoft page

101
00:04:42,630 --> 00:04:45,990
and I wanna discover all
the links on that page.

102
00:04:45,990 --> 00:04:49,137
So I'm gonna say Invoke-WebRequest

103
00:04:55,427 --> 00:05:00,427
and I am gonna go out to
https://docs.microsoft.com.

104
00:05:06,690 --> 00:05:08,340
And I wanna get information

105
00:05:08,340 --> 00:05:10,770
about all the links that are on that page

106
00:05:10,770 --> 00:05:12,633
and what their reference is.

107
00:05:15,900 --> 00:05:18,060
And what just got returned to us

108
00:05:18,060 --> 00:05:21,540
is all the links that
are embedded on that page

109
00:05:21,540 --> 00:05:25,803
both within the site and
external to the site.

110
00:05:28,200 --> 00:05:31,260
You know, these are just
some really simple examples.

111
00:05:31,260 --> 00:05:33,870
You know, you can use
each commandlet separately

112
00:05:33,870 --> 00:05:35,910
but the power of PowerShell

113
00:05:35,910 --> 00:05:39,540
is realized when you
combine these commandlets

114
00:05:39,540 --> 00:05:44,540
to perform complex tasks or
to automate repetitive tasks.

115
00:05:44,820 --> 00:05:47,850
So I really, really wanna encourage you

116
00:05:47,850 --> 00:05:49,860
to get to know PowerShell.

117
00:05:49,860 --> 00:05:52,590
And there are so many resources
available to you out there.

118
00:05:52,590 --> 00:05:54,900
There are open source resources.

119
00:05:54,900 --> 00:05:58,080
There's tons and tons of
books that have been written.

120
00:05:58,080 --> 00:06:01,530
There's great help screens
embedded in PowerShell.

121
00:06:01,530 --> 00:06:04,890
You know, getting to know
PowerShell will make your job

122
00:06:04,890 --> 00:06:07,530
a lot easier and you're
just gonna be amazed

123
00:06:07,530 --> 00:06:09,570
at all the things that you can do.

124
00:06:09,570 --> 00:06:13,650
So get to know PowerShell, you
know, really start using it.

125
00:06:13,650 --> 00:06:15,813
And that my friends, is a closer look.
