1
00:00:00,340 --> 00:00:01,860
[Autogenerated] So let's go back into our

2
00:00:01,860 --> 00:00:03,760
environment on Well, first, look at how

3
00:00:03,760 --> 00:00:06,610
we can modify Sim sessions using the

4
00:00:06,610 --> 00:00:09,140
options once we've done that, well, then,

5
00:00:09,140 --> 00:00:12,240
look at how we can executes SIM commands

6
00:00:12,240 --> 00:00:15,350
now when connecting two remote computers

7
00:00:15,350 --> 00:00:17,690
to run the SIM commands. There's obviously

8
00:00:17,690 --> 00:00:18,890
as you've talked about two different

9
00:00:18,890 --> 00:00:22,210
types, one is a temporary session and then

10
00:00:22,210 --> 00:00:24,930
one would be a more permanent session that

11
00:00:24,930 --> 00:00:27,840
we would actually have to close ourself.

12
00:00:27,840 --> 00:00:30,200
So the first thing I want to do is just

13
00:00:30,200 --> 00:00:31,770
create a new variable that we've used

14
00:00:31,770 --> 00:00:34,470
before on. We'll call this local host,

15
00:00:34,470 --> 00:00:36,680
which is just the machine that I'm on. And

16
00:00:36,680 --> 00:00:38,310
then what I'm going to do is do sim

17
00:00:38,310 --> 00:00:40,020
instantiate. Well, actually, what going to

18
00:00:40,020 --> 00:00:41,760
do first is I'm going to say, get sim

19
00:00:41,760 --> 00:00:43,990
session on, then you'll see I have some

20
00:00:43,990 --> 00:00:46,750
sessions here. So what I'm gonna do is a

21
00:00:46,750 --> 00:00:51,010
SIM session sim session, and then I'm

22
00:00:51,010 --> 00:00:53,260
going to say one No, notice what happens.

23
00:00:53,260 --> 00:00:57,470
It doesn't let me delete a SIM session by

24
00:00:57,470 --> 00:01:01,450
using the number. If I do sim or we can

25
00:01:01,450 --> 00:01:03,850
say one, you could see it errors every

26
00:01:03,850 --> 00:01:06,770
single time. So in order for us to clear

27
00:01:06,770 --> 00:01:10,460
the sessions. So if I do get same session,

28
00:01:10,460 --> 00:01:13,340
here is a list. Um, all I need to know

29
00:01:13,340 --> 00:01:16,550
what that same session is so that I could

30
00:01:16,550 --> 00:01:21,600
get rid of it. So if I do, I'm gonna call

31
00:01:21,600 --> 00:01:28,020
it session equals get sim session. And

32
00:01:28,020 --> 00:01:30,670
then, of course, you've got IDE and I can.

33
00:01:30,670 --> 00:01:37,340
Say one, then I can say remove sim session

34
00:01:37,340 --> 00:01:40,500
and apps, not server name. I want it to be

35
00:01:40,500 --> 00:01:45,270
sim Session and I can say session. Okay,

36
00:01:45,270 --> 00:01:47,750
so now if I just look back notice I have

37
00:01:47,750 --> 00:01:50,240
to So I can repeat the same process and,

38
00:01:50,240 --> 00:01:52,590
you know, go through and get the session

39
00:01:52,590 --> 00:01:55,030
I can Then remove the session I can then

40
00:01:55,030 --> 00:01:57,160
go back and get three. And then I could

41
00:01:57,160 --> 00:02:00,050
move this session, and then this time I'm

42
00:02:00,050 --> 00:02:01,220
gonna get against extension and have

43
00:02:01,220 --> 00:02:04,230
nothing. Okay, so we clear. Okay, So let

44
00:02:04,230 --> 00:02:06,640
me go back and create my variable again.

45
00:02:06,640 --> 00:02:10,260
Local host. And now what I want to do is

46
00:02:10,260 --> 00:02:13,450
use the get sim instance command, so I

47
00:02:13,450 --> 00:02:17,220
don't want to create a specific session. I

48
00:02:17,220 --> 00:02:19,280
just want to create an instance. So I'm

49
00:02:19,280 --> 00:02:20,990
going to say computer name and we'll use

50
00:02:20,990 --> 00:02:22,870
my computer if use this command multiple

51
00:02:22,870 --> 00:02:26,380
times And this time my name space. I'm

52
00:02:26,380 --> 00:02:28,410
gonna do a bit of a longer name space. So

53
00:02:28,410 --> 00:02:34,640
Sim, Version two, Terminal services. And

54
00:02:34,640 --> 00:02:38,010
then I'll do class name and we'll do win

55
00:02:38,010 --> 00:02:45,190
32 terminal services setting. Okay, So

56
00:02:45,190 --> 00:02:47,180
going to press center. That gives me all

57
00:02:47,180 --> 00:02:49,370
the information back. Now, what did that

58
00:02:49,370 --> 00:02:54,600
just do? Well, let me do get same session.

59
00:02:54,600 --> 00:02:56,790
There's no session, is there? Nothing

60
00:02:56,790 --> 00:02:59,200
exists because the gets him session

61
00:02:59,200 --> 00:03:01,330
literally just created a temporary session

62
00:03:01,330 --> 00:03:03,680
for the purpose of returning the data on,

63
00:03:03,680 --> 00:03:06,480
then deleted that session. It doesn't keep

64
00:03:06,480 --> 00:03:08,730
that session around now. That doesn't

65
00:03:08,730 --> 00:03:10,350
really help me if I want to make

66
00:03:10,350 --> 00:03:13,350
adjustments to values. So if I connect to

67
00:03:13,350 --> 00:03:15,440
the session or at least use gets, um

68
00:03:15,440 --> 00:03:16,900
instance, it's not going to make any

69
00:03:16,900 --> 00:03:19,120
adjustments because I have no session to

70
00:03:19,120 --> 00:03:22,300
utilize. So what we can do is I'm going to

71
00:03:22,300 --> 00:03:24,880
create another variable here. We'll call

72
00:03:24,880 --> 00:03:29,070
it session name and I'll call it training

73
00:03:29,070 --> 00:03:31,460
session. So I have my computer name

74
00:03:31,460 --> 00:03:34,200
already, and I have my session name. Now

75
00:03:34,200 --> 00:03:39,510
I'm going to say session equals new sim

76
00:03:39,510 --> 00:03:44,490
session. The name for that will be my

77
00:03:44,490 --> 00:03:48,550
session name and then my computer will be

78
00:03:48,550 --> 00:03:51,560
the computer. Now, what does that look

79
00:03:51,560 --> 00:03:59,580
like? If I do get same session, you'll see

80
00:03:59,580 --> 00:04:01,600
it. The session there exists. You notice

81
00:04:01,600 --> 00:04:03,570
the protocol is not decommitted to be s

82
00:04:03,570 --> 00:04:06,130
man. So we have remote connection. So if I

83
00:04:06,130 --> 00:04:08,770
clear that and then just type session,

84
00:04:08,770 --> 00:04:10,840
you'll see it brings back that one too. So

85
00:04:10,840 --> 00:04:14,310
I now have a persisted session or one that

86
00:04:14,310 --> 00:04:19,060
I can execute. That means if I wanted to

87
00:04:19,060 --> 00:04:26,390
say, get same instantiate class, well,

88
00:04:26,390 --> 00:04:30,540
you'll see that we've got okay, let me do

89
00:04:30,540 --> 00:04:35,880
class name win 32 process and then you'll

90
00:04:35,880 --> 00:04:38,560
see you saw that one that was there. I can

91
00:04:38,560 --> 00:04:40,890
then say session and it will go ahead and

92
00:04:40,890 --> 00:04:42,360
bring with that. Let's just go back and

93
00:04:42,360 --> 00:04:44,930
look at this. So I told it to retrieve all

94
00:04:44,930 --> 00:04:46,930
of the processes using that specific class

95
00:04:46,930 --> 00:04:49,030
name. Get me the instances off it. And I

96
00:04:49,030 --> 00:04:52,150
passed the existing session. So this means

97
00:04:52,150 --> 00:04:53,970
that if we're trying to write something,

98
00:04:53,970 --> 00:04:55,530
for example, that's going to execute

99
00:04:55,530 --> 00:04:58,420
against multiple machines, then we can

100
00:04:58,420 --> 00:05:01,050
create sessions on those machines and then

101
00:05:01,050 --> 00:05:04,850
call back into them as we needed then, of

102
00:05:04,850 --> 00:05:07,050
course, one of the things that we can do

103
00:05:07,050 --> 00:05:09,860
so I'm gonna say get Sim session. This

104
00:05:09,860 --> 00:05:11,920
will give you my i D number and then

105
00:05:11,920 --> 00:05:16,260
we can obviously remove the same session.

106
00:05:16,260 --> 00:05:19,450
Now, I already have this one listed here,

107
00:05:19,450 --> 00:05:25,340
So I can say session boom. And if I now do

108
00:05:25,340 --> 00:05:27,720
session, there's nothing there. So those

109
00:05:27,720 --> 00:05:30,530
sessions will hang around until you've

110
00:05:30,530 --> 00:05:33,190
kind of completed. What? The task that

111
00:05:33,190 --> 00:05:36,670
you're trying to kind of run. Now what we

112
00:05:36,670 --> 00:05:39,060
can do is we can actually modify the

113
00:05:39,060 --> 00:05:40,840
session itself. So I'm going to clear that

114
00:05:40,840 --> 00:05:43,960
down on we're going to change the actual

115
00:05:43,960 --> 00:05:48,510
session itself. So, firstly, if I do new

116
00:05:48,510 --> 00:05:56,740
SIM session option and just say a protocol

117
00:05:56,740 --> 00:05:59,250
I can do decomp and enter that now you're

118
00:05:59,250 --> 00:06:01,980
C gives me some values packet, privacy,

119
00:06:01,980 --> 00:06:05,040
packet integrity impersonate etcetera.

120
00:06:05,040 --> 00:06:07,860
Now, what that means is that when I create

121
00:06:07,860 --> 00:06:10,610
that session that's connected to that

122
00:06:10,610 --> 00:06:13,260
session option, it will adopt those that

123
00:06:13,260 --> 00:06:18,940
are there. So if I say new same session,

124
00:06:18,940 --> 00:06:22,900
let me go computer name, dollar computer

125
00:06:22,900 --> 00:06:26,000
and do that. Mm. Wait a minute. This one

126
00:06:26,000 --> 00:06:29,150
connected as ws man, but didn't utilize my

127
00:06:29,150 --> 00:06:32,470
sim session option. So let me clear that

128
00:06:32,470 --> 00:06:35,500
and let me go back to here and loop

129
00:06:35,500 --> 00:06:37,860
through the various values that we have

130
00:06:37,860 --> 00:06:39,780
available to us, and you'll see we have

131
00:06:39,780 --> 00:06:42,630
something called session option. So when

132
00:06:42,630 --> 00:06:45,620
we're defining these, I'm gonna say

133
00:06:45,620 --> 00:06:56,100
options, new SIM session option protocol.

134
00:06:56,100 --> 00:06:58,450
And I'm going to say decomp Now I'm gonna

135
00:06:58,450 --> 00:07:04,620
do my new session session options options

136
00:07:04,620 --> 00:07:07,420
and enter now we can see the difference.

137
00:07:07,420 --> 00:07:10,630
So if I do get SIM session, you can see

138
00:07:10,630 --> 00:07:12,770
there's two. There's the first one that

139
00:07:12,770 --> 00:07:15,640
was the default, which is going to default

140
00:07:15,640 --> 00:07:19,150
to do Bs man, based on the fact that I

141
00:07:19,150 --> 00:07:21,730
passed a computer name but actually with a

142
00:07:21,730 --> 00:07:25,030
SIM session option I can change that and

143
00:07:25,030 --> 00:07:27,000
say, Even though I'm passing a computer

144
00:07:27,000 --> 00:07:29,420
name, I would like you to use a different

145
00:07:29,420 --> 00:07:31,580
protocol to get to it. These key here is

146
00:07:31,580 --> 00:07:33,460
that we have to populate that session

147
00:07:33,460 --> 00:07:36,450
option to make that work, So using the

148
00:07:36,450 --> 00:07:39,460
session options allows me to kind of craft

149
00:07:39,460 --> 00:07:42,030
how I want that session to actually

150
00:07:42,030 --> 00:07:45,110
function. Now. Of course, what we can do

151
00:07:45,110 --> 00:07:48,110
is combine all of this together so we can

152
00:07:48,110 --> 00:07:50,030
go ahead and say, Well, let's retrieve a

153
00:07:50,030 --> 00:07:54,240
value. Let's update a value and then, you

154
00:07:54,240 --> 00:07:56,840
know, let's set a value if needed and this

155
00:07:56,840 --> 00:08:01,640
ties all of those commands together. So,

156
00:08:01,640 --> 00:08:03,710
as an example, we already have the

157
00:08:03,710 --> 00:08:06,700
computer name on Let's say we wanted to

158
00:08:06,700 --> 00:08:09,330
retrieve specific settings. So what I'm

159
00:08:09,330 --> 00:08:13,540
gonna do here is create a new variable.

160
00:08:13,540 --> 00:08:15,040
I'm going to call it terminal service

161
00:08:15,040 --> 00:08:19,640
Settings on. We'll say, gets in session

162
00:08:19,640 --> 00:08:23,410
and then I'm going to say Go and get me

163
00:08:23,410 --> 00:08:26,020
one of those existing sessions. Now, if I

164
00:08:26,020 --> 00:08:30,810
don't have a session, then I can say new

165
00:08:30,810 --> 00:08:34,240
same session and I could give it a name at

166
00:08:34,240 --> 00:08:36,220
this point if I wanted to. So I'm gonna

167
00:08:36,220 --> 00:08:40,620
call this one ts setting, and then I'm

168
00:08:40,620 --> 00:08:42,800
going to do a pipe out of here and say,

169
00:08:42,800 --> 00:08:45,740
Get see him instantiate because remember

170
00:08:45,740 --> 00:08:47,880
that the beauty of PowerShell is that

171
00:08:47,880 --> 00:08:50,250
we can kind of combine these all together.

172
00:08:50,250 --> 00:08:53,910
So I'm gonna say name space on. We'll call

173
00:08:53,910 --> 00:08:59,850
it Route Sim version two slash terminal

174
00:08:59,850 --> 00:09:03,510
services. Then we'll do class name and

175
00:09:03,510 --> 00:09:08,240
we'll say, win 32 terminal services

176
00:09:08,240 --> 00:09:11,890
setting like so. Okay, what does that look

177
00:09:11,890 --> 00:09:14,430
like? Well, let's hope it's got the right

178
00:09:14,430 --> 00:09:16,020
value that we're looking for. And sure

179
00:09:16,020 --> 00:09:17,740
enough, it brings me all the values that

180
00:09:17,740 --> 00:09:21,010
I'm expect him so that command allows me

181
00:09:21,010 --> 00:09:24,130
to initiate a new session with a name. So

182
00:09:24,130 --> 00:09:27,250
if I actually say get sim session, you

183
00:09:27,250 --> 00:09:29,720
should see my tear setting One is listed

184
00:09:29,720 --> 00:09:33,170
here. No, that's great. So let's repeat

185
00:09:33,170 --> 00:09:35,590
that process a little bit and we'll say,

186
00:09:35,590 --> 00:09:40,650
general setting. And I'm going to say new

187
00:09:40,650 --> 00:09:42,520
SIM session because I'm not retrieving

188
00:09:42,520 --> 00:09:46,620
one. I'm gonna call it a name and we'll

189
00:09:46,620 --> 00:09:51,920
say ts general setting like so what I'll

190
00:09:51,920 --> 00:09:56,540
now do is pipe that value out and say, Get

191
00:09:56,540 --> 00:10:03,640
Sim. I'm in capital letters there. Get Sim

192
00:10:03,640 --> 00:10:06,320
instantiate. And then, of course, I can

193
00:10:06,320 --> 00:10:09,570
pass name space and I'm going to do the

194
00:10:09,570 --> 00:10:12,580
same as before. So Route Sim version two

195
00:10:12,580 --> 00:10:19,750
slash terminal services and class name Win

196
00:10:19,750 --> 00:10:26,150
32. T s general setting apps. I have a

197
00:10:26,150 --> 00:10:28,340
plus there. That's not what I wanted.

198
00:10:28,340 --> 00:10:32,360
Like, So So now I should have they would

199
00:10:32,360 --> 00:10:35,240
go the general settings in there. Okay,

200
00:10:35,240 --> 00:10:36,550
It's always good to leave. The are is in

201
00:10:36,550 --> 00:10:38,670
there saying kind of see, I obviously

202
00:10:38,670 --> 00:10:40,370
typed the plus sign when it should have

203
00:10:40,370 --> 00:10:43,890
been nothing. So that gives me my details

204
00:10:43,890 --> 00:10:45,930
that I'm looking for now. Of course, when

205
00:10:45,930 --> 00:10:48,030
we combine all of this together. The

206
00:10:48,030 --> 00:10:51,370
beauty that we have is we have a tear

207
00:10:51,370 --> 00:10:54,080
setting, which is all of the values or the

208
00:10:54,080 --> 00:10:56,100
properties that we could change, Which

209
00:10:56,100 --> 00:11:00,310
means that I can then pass that into the

210
00:11:00,310 --> 00:11:04,880
invoke method itself. So I can say sim

211
00:11:04,880 --> 00:11:08,230
method. And then I would need to know what

212
00:11:08,230 --> 00:11:10,870
the method name would be. So in this one,

213
00:11:10,870 --> 00:11:16,000
it's called Allow t s connections. And

214
00:11:16,000 --> 00:11:17,920
then I'm going to pass. Arguments may

215
00:11:17,920 --> 00:11:20,810
remember arguments are passed inside the

216
00:11:20,810 --> 00:11:23,410
at with scroll your brackets. So I'll say

217
00:11:23,410 --> 00:11:29,840
hello. T s connections equals one. Modify

218
00:11:29,840 --> 00:11:36,310
firewall. Exceptions equals one. So let's

219
00:11:36,310 --> 00:11:38,320
just look at the command for a second. So

220
00:11:38,320 --> 00:11:40,550
I have the terminal service settings that

221
00:11:40,550 --> 00:11:42,840
I retrieved in the past and now being

222
00:11:42,840 --> 00:11:45,050
passed into the invoke method, which is

223
00:11:45,050 --> 00:11:47,550
very much like the previous invoke methods

224
00:11:47,550 --> 00:11:49,210
that we looked at, which is then going to

225
00:11:49,210 --> 00:11:52,320
execute a specific method which is called

226
00:11:52,320 --> 00:11:54,450
Settle Out es connections. And I'm going

227
00:11:54,450 --> 00:11:57,670
to pass arguments to it to then do

228
00:11:57,670 --> 00:12:01,180
something at this point. I can Then pipe

229
00:12:01,180 --> 00:12:04,360
all of that back out. So I can say format

230
00:12:04,360 --> 00:12:11,140
table. I'm gonna say property PS, computer

231
00:12:11,140 --> 00:12:17,980
name, return value and I'll auto size that

232
00:12:17,980 --> 00:12:20,590
impress center now. Of course, What you

233
00:12:20,590 --> 00:12:23,020
can see here is I'm obviously using a

234
00:12:23,020 --> 00:12:25,510
parameter that probably isn't the right

235
00:12:25,510 --> 00:12:27,760
name. I think I've got a s on the end, so

236
00:12:27,760 --> 00:12:29,520
let me just get rid of that. And this is

237
00:12:29,520 --> 00:12:31,660
why you should type all this out first.

238
00:12:31,660 --> 00:12:34,990
There we do. Okay, So it went in, it made

239
00:12:34,990 --> 00:12:37,220
adjustment and returned a value of zero,

240
00:12:37,220 --> 00:12:38,860
which is perfectly fine. I already have

241
00:12:38,860 --> 00:12:41,090
this configuration in. And I could repeat

242
00:12:41,090 --> 00:12:44,120
that process again. That would say Go and

243
00:12:44,120 --> 00:12:46,270
get me the general settings as well. Now,

244
00:12:46,270 --> 00:12:49,580
of course, what we're left with after

245
00:12:49,580 --> 00:12:52,560
running all of this together is a bunch of

246
00:12:52,560 --> 00:12:54,960
sessions. Now, if we dict created the one

247
00:12:54,960 --> 00:12:57,620
session, we could have literally used

248
00:12:57,620 --> 00:13:00,840
session .NET name and it would have

249
00:13:00,840 --> 00:13:02,760
rendered the training session one on. I

250
00:13:02,760 --> 00:13:05,410
could have reused that session over and

251
00:13:05,410 --> 00:13:07,920
over and over again because I didn't do

252
00:13:07,920 --> 00:13:10,540
that. I'm no left with multiple sessions.

253
00:13:10,540 --> 00:13:13,820
So to remove those sessions. So if I say

254
00:13:13,820 --> 00:13:18,270
remove sim session if I loop, I've got

255
00:13:18,270 --> 00:13:21,740
same session Computer name I can say local

256
00:13:21,740 --> 00:13:26,190
host gets him session and they've all

257
00:13:26,190 --> 00:13:28,150
gone. So that was one that I hadn't showed

258
00:13:28,150 --> 00:13:30,340
GUI are is the ability to remove all

259
00:13:30,340 --> 00:13:33,850
sessions by computer name in one sweep. So

260
00:13:33,850 --> 00:13:36,200
that kind of shows you how to modify

261
00:13:36,200 --> 00:13:39,660
existing sessions, how to connect to the

262
00:13:39,660 --> 00:13:41,760
to the machines, using different types of

263
00:13:41,760 --> 00:13:47,000
sessions to create remote sessions and then, of course, to execute commands.

