1
00:00:06,150 --> 00:00:10,380
- Challenge: Configuring
IP with PowerShell.

2
00:00:10,380 --> 00:00:13,020
Are you tired of clicking around the GUI?

3
00:00:13,020 --> 00:00:17,070
Use PowerShell, use the command line.

4
00:00:17,070 --> 00:00:20,910
In this lab, we'll configure a static IP

5
00:00:20,910 --> 00:00:23,913
version 4 address within PowerShell.

6
00:00:24,960 --> 00:00:27,910
To do this, we'll use the following format

7
00:00:28,920 --> 00:00:32,520
and we're gonna use the netsh command.

8
00:00:32,520 --> 00:00:36,210
This command could do all
kinds of things in Windows,

9
00:00:36,210 --> 00:00:40,410
we're just gonna use it
here to configure TCP/IP.

10
00:00:40,410 --> 00:00:43,320
And for this command we're gonna use netsh

11
00:00:43,320 --> 00:00:45,813
and a lot of options and parameters.

12
00:00:46,710 --> 00:00:51,710
It's going to be netsh
interface, IP set address

13
00:00:52,440 --> 00:00:54,480
and then your connection name.

14
00:00:54,480 --> 00:00:58,050
By default in Windows, if
you have a wired connection

15
00:00:58,050 --> 00:01:01,890
that connection's name
will be called ethernet

16
00:01:01,890 --> 00:01:04,620
and that's what I'll be
using in the demonstration

17
00:01:04,620 --> 00:01:06,480
in just a minute.

18
00:01:06,480 --> 00:01:08,820
Then we'll say static because we're going

19
00:01:08,820 --> 00:01:12,120
to manually configure the IP address

20
00:01:12,120 --> 00:01:14,820
and then we'll enter the actual IP version

21
00:01:14,820 --> 00:01:17,760
4 address that we want to use,

22
00:01:17,760 --> 00:01:21,300
as well as the IP version 4 subnet mask

23
00:01:21,300 --> 00:01:23,223
and the gateway address.

24
00:01:25,500 --> 00:01:28,770
Afterward, we'll add a DNS server

25
00:01:28,770 --> 00:01:33,770
so that we can do our
name to IP resolution.

26
00:01:33,960 --> 00:01:38,280
And once again, we'll use the
netsh interface IP command,

27
00:01:38,280 --> 00:01:42,120
but this time we'll type add DNS,

28
00:01:42,120 --> 00:01:43,980
once again our connection name

29
00:01:43,980 --> 00:01:47,820
and then the IP address of our DNS server.

30
00:01:47,820 --> 00:01:49,920
After we do that, we'll test it

31
00:01:49,920 --> 00:01:52,050
and make sure that it can function

32
00:01:52,050 --> 00:01:54,780
and that we can connect to the internet.

33
00:01:54,780 --> 00:01:58,180
When we're done, we'll set it back to DHCP

34
00:01:59,100 --> 00:02:04,100
and the command for that netsh
interface IP set address,

35
00:02:04,380 --> 00:02:07,113
the connection name and just DHCP.

36
00:02:08,700 --> 00:02:10,953
So let's get into the demonstration now.

37
00:02:11,820 --> 00:02:16,820
I'm going to be doing this on
a Windows 11 virtual machine

38
00:02:17,190 --> 00:02:22,190
and we want to open up
PowerShell as an administrator.

39
00:02:22,830 --> 00:02:25,380
Several ways to do this.

40
00:02:25,380 --> 00:02:28,080
In Windows 11 you could
right click on start

41
00:02:28,080 --> 00:02:29,580
and open Windows Terminal,

42
00:02:29,580 --> 00:02:32,070
which will automatically open PowerShell.

43
00:02:32,070 --> 00:02:34,233
And you'd wanna do that as an admin,

44
00:02:35,160 --> 00:02:38,520
or we could press the Windows key

45
00:02:38,520 --> 00:02:41,280
and type in PowerShell

46
00:02:41,280 --> 00:02:42,810
and run it from there,

47
00:02:42,810 --> 00:02:46,380
or do it from the run
prompt and type PowerShell.

48
00:02:46,380 --> 00:02:50,890
And to run it as an admin
we'd press control shift enter

49
00:02:51,960 --> 00:02:53,700
but I like the search option.

50
00:02:53,700 --> 00:02:54,810
It's very easy.

51
00:02:54,810 --> 00:02:57,540
We can right click on Windows PowerShell

52
00:02:57,540 --> 00:02:59,733
and select run as administrator.

53
00:03:01,793 --> 00:03:02,770
And we'll say yes

54
00:03:04,020 --> 00:03:06,570
and that brings up the Windows PowerShell

55
00:03:06,570 --> 00:03:09,930
as an administrator,
meaning in elevated mode.

56
00:03:09,930 --> 00:03:12,150
So now we can do these types of commands

57
00:03:12,150 --> 00:03:14,940
that we need to do as an admin.

58
00:03:14,940 --> 00:03:18,360
I'm going to change to the root directory

59
00:03:18,360 --> 00:03:20,490
and clear the screen with a control L

60
00:03:20,490 --> 00:03:23,370
so that we have a little
bit more space here.

61
00:03:23,370 --> 00:03:24,630
And the first thing I wanna do

62
00:03:24,630 --> 00:03:28,053
is run an IP config slash all,

63
00:03:28,890 --> 00:03:32,103
to check out the current IP configuration.

64
00:03:33,270 --> 00:03:36,180
Now, as I mentioned,
this is a virtual machine

65
00:03:36,180 --> 00:03:40,620
and it's on a virtualization platform

66
00:03:40,620 --> 00:03:45,090
that automatically hands out IP addresses.

67
00:03:45,090 --> 00:03:47,340
I know that this virtual machine

68
00:03:47,340 --> 00:03:50,790
is obtaining its IP
address from a DHCP server.

69
00:03:50,790 --> 00:03:54,810
I know that because here
it says DHCP enabled

70
00:03:54,810 --> 00:03:56,460
and yes.

71
00:03:56,460 --> 00:03:59,190
So we know we're getting
our TCP/IP information

72
00:03:59,190 --> 00:04:00,930
from a DHCP server.

73
00:04:00,930 --> 00:04:03,840
And that's the DHCP
server that's built into

74
00:04:03,840 --> 00:04:05,643
my virtualization platform.

75
00:04:07,410 --> 00:04:10,470
The IP version 4 address that we received

76
00:04:10,470 --> 00:04:15,470
is 192.168.122.63.

77
00:04:15,900 --> 00:04:19,440
So the IP network that my
virtualization platform

78
00:04:19,440 --> 00:04:23,250
is using here is 192.168.122.

79
00:04:23,250 --> 00:04:26,940
I wanna stay on that particular network.

80
00:04:26,940 --> 00:04:30,510
What differentiates this
system from other systems

81
00:04:30,510 --> 00:04:33,633
is the last octet, that dot 63.

82
00:04:34,590 --> 00:04:39,270
And I'll be changing that when
we set a static IP address.

83
00:04:39,270 --> 00:04:41,790
We're also getting the
subnet mask information

84
00:04:41,790 --> 00:04:46,443
from the DHCP server
which is 255.255.255.0.

85
00:04:48,270 --> 00:04:50,460
We also see the default gateway

86
00:04:50,460 --> 00:04:55,020
which is 192.168.122.1,

87
00:04:55,020 --> 00:04:59,670
and the DNS server,
which is the same host.

88
00:04:59,670 --> 00:05:03,900
Now you might do this on a
network with the Soho router

89
00:05:03,900 --> 00:05:05,730
and it would work in the same manner.

90
00:05:05,730 --> 00:05:09,630
Your network might be 192.168.0,

91
00:05:09,630 --> 00:05:12,480
or 192.168.1.

92
00:05:12,480 --> 00:05:14,730
Or if you're on a different
virtualization platform,

93
00:05:14,730 --> 00:05:17,070
it might be a different network as well.

94
00:05:17,070 --> 00:05:18,900
So whatever that network is,

95
00:05:18,900 --> 00:05:22,350
that's the network that
you want to work within.

96
00:05:22,350 --> 00:05:23,640
So I'm gonna change this now,

97
00:05:23,640 --> 00:05:26,580
I don't want to have DHCP anymore.

98
00:05:26,580 --> 00:05:28,830
A lot of times I'll be working on a system

99
00:05:28,830 --> 00:05:32,790
and I want it to have a static IP address

100
00:05:32,790 --> 00:05:37,590
so that I know the IP
address will not change

101
00:05:37,590 --> 00:05:39,360
and I can have permanent connections

102
00:05:39,360 --> 00:05:42,440
to that system via that static IP.

103
00:05:42,440 --> 00:05:45,300
So a lot of times I'll
use a static IP address.

104
00:05:45,300 --> 00:05:47,640
So let's make the change now.

105
00:05:47,640 --> 00:05:50,070
We're gonna do that with the netsh command

106
00:05:50,070 --> 00:05:52,470
and that's gonna be interface

107
00:05:52,470 --> 00:05:56,880
and IP set address.

108
00:05:56,880 --> 00:05:58,350
And then we need the name

109
00:05:58,350 --> 00:06:02,970
of our wired network interface card.

110
00:06:02,970 --> 00:06:05,040
Now, again, this is a virtual machine

111
00:06:05,040 --> 00:06:07,680
so it uses virtualized hardware,

112
00:06:07,680 --> 00:06:10,470
but it works the same
way as a physical system.

113
00:06:10,470 --> 00:06:13,170
And what we wanna look
for is ethernet adapter

114
00:06:13,170 --> 00:06:15,480
and then the name that's after that.

115
00:06:15,480 --> 00:06:17,400
By default in Windows,

116
00:06:17,400 --> 00:06:21,660
the name of a wired
connection is called ethernet.

117
00:06:21,660 --> 00:06:23,580
If you're working with
a wireless connection,

118
00:06:23,580 --> 00:06:25,263
the default name is wifi.

119
00:06:26,130 --> 00:06:29,280
You could change this in the
PowerShell if you wanted to,

120
00:06:29,280 --> 00:06:32,460
but we're gonna stick
with the name ethernet.

121
00:06:32,460 --> 00:06:34,443
And we wanna put that in double quotes.

122
00:06:36,030 --> 00:06:37,170
So we'll add that in now,

123
00:06:37,170 --> 00:06:39,020
you can see the different color there

124
00:06:39,930 --> 00:06:42,270
and then we want to state

125
00:06:42,270 --> 00:06:45,210
that we are going to
add a static IP address.

126
00:06:45,210 --> 00:06:46,860
So we put in the word static

127
00:06:46,860 --> 00:06:48,960
and then the IP address I want to use.

128
00:06:48,960 --> 00:06:51,840
Well, I'm gonna use the same network

129
00:06:51,840 --> 00:06:53,760
but I'm gonna change the last octet.

130
00:06:53,760 --> 00:06:58,760
And I'm just gonna change it to say, .150.

131
00:06:59,430 --> 00:07:00,900
It doesn't really matter,

132
00:07:00,900 --> 00:07:05,900
as long as the address that
I select is not being used

133
00:07:06,030 --> 00:07:08,070
by any other systems.

134
00:07:08,070 --> 00:07:13,070
So I'm going to type 192.168.122.150.

135
00:07:14,580 --> 00:07:17,400
Next, we need the subnet mask

136
00:07:17,400 --> 00:07:19,350
and I'm gonna use the same subnet mask

137
00:07:19,350 --> 00:07:21,040
that I'm currently using,

138
00:07:21,040 --> 00:07:23,640
255.255.255.0.

139
00:07:23,640 --> 00:07:26,700
And that just wrapped
around the screen there.

140
00:07:26,700 --> 00:07:30,120
Now you could also do something like this

141
00:07:30,120 --> 00:07:31,503
slash 24,

142
00:07:32,730 --> 00:07:34,470
which is cidr notation,

143
00:07:34,470 --> 00:07:36,300
it's the same thing.

144
00:07:36,300 --> 00:07:41,300
For now I'll just do 255.255.255.0,

145
00:07:42,030 --> 00:07:43,860
and then we need to know
the gateway address.

146
00:07:43,860 --> 00:07:47,190
It's gonna be the same default gateway.

147
00:07:47,190 --> 00:07:49,290
So we'll type in this IP.

148
00:07:49,290 --> 00:07:52,200
For you, it may be
different on your system.

149
00:07:52,200 --> 00:07:55,590
It probably will be, but
that's the IP for me,

150
00:07:55,590 --> 00:07:58,770
192.168.122.1.

151
00:07:58,770 --> 00:08:00,663
And that's it, that's our command.

152
00:08:01,680 --> 00:08:02,763
So we'll press enter,

153
00:08:04,350 --> 00:08:07,350
that will apply the new information,

154
00:08:07,350 --> 00:08:11,580
deactivate and reactivate
the network interface.

155
00:08:11,580 --> 00:08:14,943
And then we can check that
with an IP config slash all.

156
00:08:16,980 --> 00:08:21,907
Okay. Now, when we look at
DHCP enabled, it says, no.

157
00:08:23,310 --> 00:08:26,340
We're not using DHCP
anymore, it's a static IP.

158
00:08:26,340 --> 00:08:28,980
When we look at the IP version 4 address,

159
00:08:28,980 --> 00:08:33,980
we see 192.168.122.150.

160
00:08:34,740 --> 00:08:36,990
And we have our default gateway.

161
00:08:36,990 --> 00:08:41,100
Now the DNS server is already there,

162
00:08:41,100 --> 00:08:44,160
but if you had a problem with that,

163
00:08:44,160 --> 00:08:46,260
if there was an issue with DNS,

164
00:08:46,260 --> 00:08:47,820
you could add that on

165
00:08:47,820 --> 00:08:52,780
and you would do that with the
netsh interface IP, add DNS

166
00:08:55,140 --> 00:08:57,700
for our ethernet connection

167
00:08:58,860 --> 00:09:03,240
and then specify the IP
address 192.168.122.1.

168
00:09:06,450 --> 00:09:08,700
And it says the object
is already in the list,

169
00:09:08,700 --> 00:09:11,670
but just in the case that it wasn't there,

170
00:09:11,670 --> 00:09:14,160
if you lost it for some reason,

171
00:09:14,160 --> 00:09:17,490
or it didn't show up when
you changed over to static,

172
00:09:17,490 --> 00:09:20,400
then you could add that with this command.

173
00:09:20,400 --> 00:09:24,180
Now we want to go ahead and
test it and make sure it works.

174
00:09:24,180 --> 00:09:26,710
So I'm gonna ping a website

175
00:09:27,720 --> 00:09:28,553
on the internet

176
00:09:29,790 --> 00:09:31,710
and we get replies.

177
00:09:31,710 --> 00:09:35,040
We can ping Depro Computer so
we know the test has passed

178
00:09:35,040 --> 00:09:37,440
and we should be able to
do anything we need to do

179
00:09:37,440 --> 00:09:40,890
with our internet connection,
inbound and outbound.

180
00:09:40,890 --> 00:09:41,723
That's it.

181
00:09:41,723 --> 00:09:44,253
That's how you change to a static IP.

182
00:09:45,240 --> 00:09:48,300
Now let's go ahead and
change it back to DHCP.

183
00:09:48,300 --> 00:09:53,300
And we'll do that with the
netsh interface IP set address

184
00:09:56,670 --> 00:10:01,293
and the name's ethernet,
and just say DHCP.

185
00:10:02,280 --> 00:10:04,530
That's gonna make the change deactivate

186
00:10:04,530 --> 00:10:07,050
and reactivate the network interface.

187
00:10:07,050 --> 00:10:09,330
And then I'll just up arrow

188
00:10:09,330 --> 00:10:12,093
to IP config slash all to check it.

189
00:10:13,140 --> 00:10:16,593
Once again, DHCP enabled, yes.

190
00:10:19,230 --> 00:10:22,860
IP version 4 address dot 63.

191
00:10:22,860 --> 00:10:27,153
Well, Windows remembers the
IP address that we were using.

192
00:10:28,320 --> 00:10:29,790
And it reapplies to that,

193
00:10:29,790 --> 00:10:32,343
as long as the DHCP
server is okay with that.

194
00:10:33,390 --> 00:10:35,310
Our gateway address is there

195
00:10:35,310 --> 00:10:38,490
and our DNS server is there.

196
00:10:38,490 --> 00:10:40,563
We'll test once again with a ping,

197
00:10:41,580 --> 00:10:42,513
all as well.

198
00:10:43,890 --> 00:10:46,980
Okay? So the only things
you might change with that

199
00:10:46,980 --> 00:10:48,330
are your network number.

200
00:10:48,330 --> 00:10:51,240
You want to put in whatever
network number you're using.

201
00:10:51,240 --> 00:10:53,040
For example, if you're on VirtualBox

202
00:10:53,040 --> 00:10:55,443
you're probably on 10.0.2.

203
00:10:56,280 --> 00:10:58,440
If you're on VMware Workstation,

204
00:10:58,440 --> 00:11:01,650
you might be using
another 192.168 network.

205
00:11:01,650 --> 00:11:03,450
If you're working on
the local area network

206
00:11:03,450 --> 00:11:05,790
on a test computer, like a laptop

207
00:11:05,790 --> 00:11:07,230
and you have a Soho network

208
00:11:07,230 --> 00:11:12,060
it might be 192.168.0,
or .1, or what have you.

209
00:11:12,060 --> 00:11:15,150
And the name of the
adapter, if it's wired,

210
00:11:15,150 --> 00:11:17,130
by default will be ethernet.

211
00:11:17,130 --> 00:11:20,880
By default, if it's
wireless, it'll be wifi.

212
00:11:20,880 --> 00:11:23,280
And make sure you put
that in double quotes.

213
00:11:23,280 --> 00:11:26,700
Now you'll notice that we
have the blue background here.

214
00:11:26,700 --> 00:11:30,933
If we were to run the command
dollar sign PS version table,

215
00:11:32,580 --> 00:11:35,520
you'll see that the PowerShell version

216
00:11:35,520 --> 00:11:37,680
that I'm running is 5.1.

217
00:11:37,680 --> 00:11:39,300
This is an older version.

218
00:11:39,300 --> 00:11:42,720
We have much newer versions of PowerShell.

219
00:11:42,720 --> 00:11:45,150
And so in another challenge video

220
00:11:45,150 --> 00:11:49,350
we'll show how to update
PowerShell to a newer version.

221
00:11:49,350 --> 00:11:51,270
Now, one other thing here,

222
00:11:51,270 --> 00:11:52,710
sometimes we'll be working on a system

223
00:11:52,710 --> 00:11:55,770
that has lots of network connections.

224
00:11:55,770 --> 00:11:58,080
For example, here's a Windows laptop.

225
00:11:58,080 --> 00:12:01,833
I'm gonna open up PowerShell
on here as an administrator,

226
00:12:02,970 --> 00:12:06,360
say yes to that, bring that up.

227
00:12:06,360 --> 00:12:11,360
And if I run an IP config
on here with a slash all,

228
00:12:11,820 --> 00:12:15,480
you're gonna see tons and
tons and tons of information

229
00:12:15,480 --> 00:12:17,640
and the Bluetooth and the wireless

230
00:12:17,640 --> 00:12:19,140
aren't even connected right now.

231
00:12:19,140 --> 00:12:21,900
So it's limited, but there's
still tons of information.

232
00:12:21,900 --> 00:12:23,490
There's all kinds of virtual networks

233
00:12:23,490 --> 00:12:26,220
and wired connection and blah, blah, blah.

234
00:12:26,220 --> 00:12:29,250
That's a lot of information to look at

235
00:12:29,250 --> 00:12:31,440
within IP config slash all.

236
00:12:31,440 --> 00:12:33,150
So if you're working on a server

237
00:12:33,150 --> 00:12:34,680
with lots of network connections,

238
00:12:34,680 --> 00:12:37,860
or if you're working on
a power works station

239
00:12:37,860 --> 00:12:40,800
with lots of connections
or maybe a developer laptop

240
00:12:40,800 --> 00:12:43,140
with lots of virtual connections,

241
00:12:43,140 --> 00:12:46,200
sometimes you may wanna
filter this information.

242
00:12:46,200 --> 00:12:49,170
So you might do an IP config slash all

243
00:12:49,170 --> 00:12:51,060
with the pipe sign

244
00:12:51,060 --> 00:12:56,060
and do select string, run
the SLS parameter here

245
00:12:56,280 --> 00:12:59,910
and then filter for what you want.

246
00:12:59,910 --> 00:13:03,930
So for example, I might
filter for description

247
00:13:03,930 --> 00:13:07,770
and also IP version 4.

248
00:13:07,770 --> 00:13:09,090
When I do that,

249
00:13:09,090 --> 00:13:12,870
I get a lot less information
and just what I want.

250
00:13:12,870 --> 00:13:15,690
So for example, description,

251
00:13:15,690 --> 00:13:18,600
real tech PCI express controller.

252
00:13:18,600 --> 00:13:20,940
That's the wired connection

253
00:13:20,940 --> 00:13:25,940
and its IP version 4
address is 10.42.0.250.

254
00:13:27,300 --> 00:13:29,520
And you can do that
for each of these here,

255
00:13:29,520 --> 00:13:30,990
all of the connections.

256
00:13:30,990 --> 00:13:35,130
So just a quick little
trick there, use SLS

257
00:13:35,130 --> 00:13:38,130
to filter out results of commands

258
00:13:38,130 --> 00:13:39,930
that give you tons of information,

259
00:13:39,930 --> 00:13:41,343
just a little bonus there.

260
00:13:42,180 --> 00:13:43,013
All right.

261
00:13:43,013 --> 00:13:45,660
And like I said, in a future
video we'll show how to upgrade

262
00:13:45,660 --> 00:13:48,960
to the latest stable
version of PowerShell.

263
00:13:48,960 --> 00:13:52,500
And in closing, go ahead now,

264
00:13:52,500 --> 00:13:57,120
I challenge you to try
configuring a new IP address

265
00:13:57,120 --> 00:14:02,070
on a test Windows system, now
I recommend a virtual machine

266
00:14:02,070 --> 00:14:04,950
but some test system
always do all this stuff

267
00:14:04,950 --> 00:14:09,300
on testing systems, not your main system.

268
00:14:09,300 --> 00:14:12,960
And remember to run
PowerShell as an admin,

269
00:14:12,960 --> 00:14:17,190
chances are you will need
PowerShell in the field.

270
00:14:17,190 --> 00:14:18,393
Use it.
