1
00:00:00,140 --> 00:00:01,490
[Autogenerated] So how do we connect to a

2
00:00:01,490 --> 00:00:03,250
remote computer? Because in reality,

3
00:00:03,250 --> 00:00:04,310
that's one of the things that we're going

4
00:00:04,310 --> 00:00:06,960
to do is try and connect. Now, this is a

5
00:00:06,960 --> 00:00:08,910
simple Now, if I'm just retrieving

6
00:00:08,910 --> 00:00:11,820
information using W. M, I I can say, get

7
00:00:11,820 --> 00:00:14,370
to be my object now. This time I'm looking

8
00:00:14,370 --> 00:00:16,960
for operating system information and then

9
00:00:16,960 --> 00:00:19,950
I'm using computer name local host now. In

10
00:00:19,950 --> 00:00:21,650
fact, I don't actually need to pass that

11
00:00:21,650 --> 00:00:24,730
to do a local connection because the

12
00:00:24,730 --> 00:00:27,060
computer named Parameter is only used for

13
00:00:27,060 --> 00:00:29,540
remote connections. So, for example, if

14
00:00:29,540 --> 00:00:31,880
I'm trying to connect to remote computer

15
00:00:31,880 --> 00:00:34,440
I can populate a variable called Trainer,

16
00:00:34,440 --> 00:00:37,480
which is my machine, and then I pass that

17
00:00:37,480 --> 00:00:39,810
variable into that parameter that will

18
00:00:39,810 --> 00:00:42,950
then initiate that same command. So go and

19
00:00:42,950 --> 00:00:45,240
get me the operating system information,

20
00:00:45,240 --> 00:00:47,320
but pass it to the computer that we

21
00:00:47,320 --> 00:00:50,780
specified. Now we can also pass

22
00:00:50,780 --> 00:00:52,470
credentials because there may be times

23
00:00:52,470 --> 00:00:54,460
where the credential that you are logged

24
00:00:54,460 --> 00:00:57,130
in with clearly doesn't have access to the

25
00:00:57,130 --> 00:00:58,830
machine that you're trying to get to or

26
00:00:58,830 --> 00:01:00,920
doesn't have the right elevation that's

27
00:01:00,920 --> 00:01:02,950
needed. So we do have some extra

28
00:01:02,950 --> 00:01:04,970
properties available to us, such as

29
00:01:04,970 --> 00:01:07,770
impersonation and credential. So what this

30
00:01:07,770 --> 00:01:10,030
allows us to do is specify the

31
00:01:10,030 --> 00:01:12,210
impersonation type, and there's a couple

32
00:01:12,210 --> 00:01:13,920
of different types here. And then, of

33
00:01:13,920 --> 00:01:16,320
course, we can pass a domain and account

34
00:01:16,320 --> 00:01:19,080
credential in this example Here. This will

35
00:01:19,080 --> 00:01:21,620
connect me to a different name space. Go

36
00:01:21,620 --> 00:01:24,000
and access the process information that's

37
00:01:24,000 --> 00:01:26,210
on that remote machine because I'm passing

38
00:01:26,210 --> 00:01:28,410
a computer name to it and then ensure that

39
00:01:28,410 --> 00:01:30,730
we log in with the right credential. Now,

40
00:01:30,730 --> 00:01:33,000
when you execute this command, it will ask

41
00:01:33,000 --> 00:01:38,040
you for the password for that credential.

42
00:01:38,040 --> 00:01:39,680
So how do we retrieve computer

43
00:01:39,680 --> 00:01:41,540
information? So we know that we can get

44
00:01:41,540 --> 00:01:43,510
the classes in the name spaces using get

45
00:01:43,510 --> 00:01:45,740
to be my object. We also know that we can

46
00:01:45,740 --> 00:01:48,350
connect to other machines. But how do we

47
00:01:48,350 --> 00:01:51,720
retrieve information? Well, this then

48
00:01:51,720 --> 00:01:54,250
becomes a simple as determining the class

49
00:01:54,250 --> 00:01:55,880
that we want to get as well as the

50
00:01:55,880 --> 00:01:58,260
properties. So you can see that we start

51
00:01:58,260 --> 00:02:01,050
into combine some of these kind of

52
00:02:01,050 --> 00:02:03,390
standard PowerShell capabilities together.

53
00:02:03,390 --> 00:02:06,400
So I can use get to be my object past the

54
00:02:06,400 --> 00:02:07,880
computer name again. So this is for a

55
00:02:07,880 --> 00:02:10,580
remote machine I can Then say this is the

56
00:02:10,580 --> 00:02:13,200
class which is my operating system. And

57
00:02:13,200 --> 00:02:15,350
then, as we've talked about in the past in

58
00:02:15,350 --> 00:02:17,670
all the PowerShell courses we can then use

59
00:02:17,670 --> 00:02:19,870
the pipe cmdlet, which will then send that

60
00:02:19,870 --> 00:02:23,030
information to the next cmdlet is select

61
00:02:23,030 --> 00:02:25,620
object Select object will then allow me to

62
00:02:25,620 --> 00:02:27,600
say, Well, which property would you like

63
00:02:27,600 --> 00:02:29,980
to select? And because I'm using this star

64
00:02:29,980 --> 00:02:32,490
or the Asterix, it will return all of the

65
00:02:32,490 --> 00:02:35,070
properties that are available. So it's a

66
00:02:35,070 --> 00:02:37,820
way of identifying the list of properties.

67
00:02:37,820 --> 00:02:39,180
Now, of course, this could be hundreds of

68
00:02:39,180 --> 00:02:42,150
properties or even more so, One of things

69
00:02:42,150 --> 00:02:44,630
that we can do is get specific properties

70
00:02:44,630 --> 00:02:47,400
back. So think of the same command. We've

71
00:02:47,400 --> 00:02:50,940
populated the computer. We have an object

72
00:02:50,940 --> 00:02:53,820
and were populating the object using W. M.

73
00:02:53,820 --> 00:02:55,940
I object to the computer again and have

74
00:02:55,940 --> 00:02:57,770
told it to go and get the operating system

75
00:02:57,770 --> 00:03:00,820
information. What we can then do is take

76
00:03:00,820 --> 00:03:03,410
that object we created, which has all the

77
00:03:03,410 --> 00:03:06,000
operating system details into it on then

78
00:03:06,000 --> 00:03:09,530
select object property and then we can

79
00:03:09,530 --> 00:03:11,770
say, Go and get me the caption on the

80
00:03:11,770 --> 00:03:17,240
manufacturer. So fairly straightforward.

81
00:03:17,240 --> 00:03:19,030
Now, of course, our next thing to do is to

82
00:03:19,030 --> 00:03:21,770
retrieve computer information. Now this

83
00:03:21,770 --> 00:03:24,110
could be done by using the same command.

84
00:03:24,110 --> 00:03:26,630
So get to be my object on past the

85
00:03:26,630 --> 00:03:28,540
computer name. And then we specify the

86
00:03:28,540 --> 00:03:30,500
class. So the kind of three standard

87
00:03:30,500 --> 00:03:32,530
things that we do. But as with all

88
00:03:32,530 --> 00:03:34,800
PowerShell commands, we can actually pipe

89
00:03:34,800 --> 00:03:37,890
the value that comes back from one of

90
00:03:37,890 --> 00:03:41,950
those and pass it into another object. So

91
00:03:41,950 --> 00:03:43,980
what I'm doing here is saying Go and get

92
00:03:43,980 --> 00:03:46,810
me the operating system details and then

93
00:03:46,810 --> 00:03:49,600
simply pass it to select object. And then

94
00:03:49,600 --> 00:03:51,760
the property value is set to star, which

95
00:03:51,760 --> 00:03:54,350
will return all of the properties. Now,

96
00:03:54,350 --> 00:03:56,490
just be aware that sometimes you may get

97
00:03:56,490 --> 00:03:58,990
one property back. Sometimes you may get

98
00:03:58,990 --> 00:04:01,240
hundreds of properties back, so it's

99
00:04:01,240 --> 00:04:02,760
important to understand that we need to do

100
00:04:02,760 --> 00:04:04,700
something to make it kind of more user

101
00:04:04,700 --> 00:04:07,310
friendly. So one thing we can do is take

102
00:04:07,310 --> 00:04:10,170
the same command that we just ran past the

103
00:04:10,170 --> 00:04:12,470
computer name. Get the object that to be

104
00:04:12,470 --> 00:04:15,860
my object for operating system and then

105
00:04:15,860 --> 00:04:18,940
we can take the results of that and pass

106
00:04:18,940 --> 00:04:21,290
those into that select object we can do

107
00:04:21,290 --> 00:04:24,090
select Azure object property star, put it

108
00:04:24,090 --> 00:04:25,970
in parentheses, and then choose the

109
00:04:25,970 --> 00:04:28,360
property so caption manufacturer, for

110
00:04:28,360 --> 00:04:31,340
example. So this, for example, will return

111
00:04:31,340 --> 00:04:34,270
Windows 10. And it'll say Microsoft is the

112
00:04:34,270 --> 00:04:36,390
manufacturer, so we can retrieve

113
00:04:36,390 --> 00:04:40,710
information quite easily using W. My. We

114
00:04:40,710 --> 00:04:43,540
also have the ability to perform actions

115
00:04:43,540 --> 00:04:46,100
on other machines. So at the moment we've

116
00:04:46,100 --> 00:04:48,660
just focused on getting information, which

117
00:04:48,660 --> 00:04:50,720
is predominantly what people would use W

118
00:04:50,720 --> 00:04:51,970
my four. They want to retrieve

119
00:04:51,970 --> 00:04:53,980
information. Let's say you have in a state

120
00:04:53,980 --> 00:04:56,620
of 1000 desktops and you want to know the

121
00:04:56,620 --> 00:04:58,370
applications that have been installed on

122
00:04:58,370 --> 00:05:00,930
those machines you could executable

123
00:05:00,930 --> 00:05:03,650
commands and do and find out what all

124
00:05:03,650 --> 00:05:05,640
those machines have. But actually you

125
00:05:05,640 --> 00:05:08,230
might want to manage. So, for example,

126
00:05:08,230 --> 00:05:10,400
let's say you wanted to retrieve the

127
00:05:10,400 --> 00:05:12,560
Windows update service details, you know,

128
00:05:12,560 --> 00:05:15,150
is that service actually executing on that

129
00:05:15,150 --> 00:05:18,120
machine? So we can still get get to be my

130
00:05:18,120 --> 00:05:21,130
object on we can Go in this time specify a

131
00:05:21,130 --> 00:05:23,010
different class, but your notice were

132
00:05:23,010 --> 00:05:25,060
introduced another parameter called

133
00:05:25,060 --> 00:05:27,560
filter. So instead of it being Queary,

134
00:05:27,560 --> 00:05:30,350
where you would say select star from now

135
00:05:30,350 --> 00:05:32,870
we can do filter, which is effectively a

136
00:05:32,870 --> 00:05:35,090
key value pair. So it's the name of the

137
00:05:35,090 --> 00:05:37,710
field or the property, and then the value

138
00:05:37,710 --> 00:05:40,190
associated to that. So this will now

139
00:05:40,190 --> 00:05:43,690
return the specific service details for

140
00:05:43,690 --> 00:05:46,820
the Windows Update services. What we can

141
00:05:46,820 --> 00:05:49,970
then do is use what's called Get Dash

142
00:05:49,970 --> 00:05:53,420
member. Now, this isn't a W my command.

143
00:05:53,420 --> 00:05:55,020
This is just a standard PowerShell

144
00:05:55,020 --> 00:05:57,220
command. But Member, how we can use the

145
00:05:57,220 --> 00:05:59,560
pipe command to pass through. So now I

146
00:05:59,560 --> 00:06:01,620
have my service object, which is the

147
00:06:01,620 --> 00:06:03,790
Windows Update service. I can pass it to

148
00:06:03,790 --> 00:06:06,470
get member on. What does get member do? It

149
00:06:06,470 --> 00:06:08,700
gives me the list of methods that are

150
00:06:08,700 --> 00:06:12,590
available. A method is an action, so

151
00:06:12,590 --> 00:06:15,060
something that can happen. So does it have

152
00:06:15,060 --> 00:06:16,870
a start method? Does it have a stop

153
00:06:16,870 --> 00:06:19,500
method? Once we've identified that, then

154
00:06:19,500 --> 00:06:21,430
we can get the name for that which won't

155
00:06:21,430 --> 00:06:23,290
come back a start and stop unless that's

156
00:06:23,290 --> 00:06:25,860
what the service has in this example. The

157
00:06:25,860 --> 00:06:28,540
Windows Update service has a stop services

158
00:06:28,540 --> 00:06:31,820
and start services. So I can then execute

159
00:06:31,820 --> 00:06:35,220
a start and stop on. What's powerful here

160
00:06:35,220 --> 00:06:38,530
is that this is being done from my machine

161
00:06:38,530 --> 00:06:41,400
to a remote computer or it could be done

162
00:06:41,400 --> 00:06:44,590
locally. So I can now retrieve information

163
00:06:44,590 --> 00:06:48,130
about a service, check the methods to make

164
00:06:48,130 --> 00:06:51,150
sure I can do an action and then start or

165
00:06:51,150 --> 00:06:54,000
stop or perform the relative action that's required

