[Autogenerated] So how do we connect to a
remote computer? Because in reality,
that's one of the things that we're going
to do is try and connect. Now, this is a
simple Now, if I'm just retrieving
information using W. M, I I can say, get
to be my object now. This time I'm looking
for operating system information and then
I'm using computer name local host now. In
fact, I don't actually need to pass that
to do a local connection because the
computer named Parameter is only used for
remote connections. So, for example, if
I'm trying to connect to remote computer
I can populate a variable called Trainer,
which is my machine, and then I pass that
variable into that parameter that will
then initiate that same command. So go and
get me the operating system information,
but pass it to the computer that we
specified. Now we can also pass
credentials because there may be times
where the credential that you are logged
in with clearly doesn't have access to the
machine that you're trying to get to or
doesn't have the right elevation that's
needed. So we do have some extra
properties available to us, such as
impersonation and credential. So what this
allows us to do is specify the
impersonation type, and there's a couple
of different types here. And then, of
course, we can pass a domain and account
credential in this example Here. This will
connect me to a different name space. Go
and access the process information that's
on that remote machine because I'm passing
a computer name to it and then ensure that
we log in with the right credential. Now,
when you execute this command, it will ask
you for the password for that credential.
So how do we retrieve computer
information? So we know that we can get
the classes in the name spaces using get
to be my object. We also know that we can
connect to other machines. But how do we
retrieve information? Well, this then
becomes a simple as determining the class
that we want to get as well as the
properties. So you can see that we start
into combine some of these kind of
standard PowerShell capabilities together.
So I can use get to be my object past the
computer name again. So this is for a
remote machine I can Then say this is the
class which is my operating system. And
then, as we've talked about in the past in
all the PowerShell courses we can then use
the pipe cmdlet, which will then send that
information to the next cmdlet is select
object Select object will then allow me to
say, Well, which property would you like
to select? And because I'm using this star
or the Asterix, it will return all of the
properties that are available. So it's a
way of identifying the list of properties.
Now, of course, this could be hundreds of
properties or even more so, One of things
that we can do is get specific properties
back. So think of the same command. We've
populated the computer. We have an object
and were populating the object using W. M.
I object to the computer again and have
told it to go and get the operating system
information. What we can then do is take
that object we created, which has all the
operating system details into it on then
select object property and then we can
say, Go and get me the caption on the
manufacturer. So fairly straightforward.
Now, of course, our next thing to do is to
retrieve computer information. Now this
could be done by using the same command.
So get to be my object on past the
computer name. And then we specify the
class. So the kind of three standard
things that we do. But as with all
PowerShell commands, we can actually pipe
the value that comes back from one of
those and pass it into another object. So
what I'm doing here is saying Go and get
me the operating system details and then
simply pass it to select object. And then
the property value is set to star, which
will return all of the properties. Now,
just be aware that sometimes you may get
one property back. Sometimes you may get
hundreds of properties back, so it's
important to understand that we need to do
something to make it kind of more user
friendly. So one thing we can do is take
the same command that we just ran past the
computer name. Get the object that to be
my object for operating system and then
we can take the results of that and pass
those into that select object we can do
select Azure object property star, put it
in parentheses, and then choose the
property so caption manufacturer, for
example. So this, for example, will return
Windows 10. And it'll say Microsoft is the
manufacturer, so we can retrieve
information quite easily using W. My. We
also have the ability to perform actions
on other machines. So at the moment we've
just focused on getting information, which
is predominantly what people would use W
my four. They want to retrieve
information. Let's say you have in a state
of 1000 desktops and you want to know the
applications that have been installed on
those machines you could executable
commands and do and find out what all
those machines have. But actually you
might want to manage. So, for example,
let's say you wanted to retrieve the
Windows update service details, you know,
is that service actually executing on that
machine? So we can still get get to be my
object on we can Go in this time specify a
different class, but your notice were
introduced another parameter called
filter. So instead of it being Queary,
where you would say select star from now
we can do filter, which is effectively a
key value pair. So it's the name of the
field or the property, and then the value
associated to that. So this will now
return the specific service details for
the Windows Update services. What we can
then do is use what's called Get Dash
member. Now, this isn't a W my command.
This is just a standard PowerShell
command. But Member, how we can use the
pipe command to pass through. So now I
have my service object, which is the
Windows Update service. I can pass it to
get member on. What does get member do? It
gives me the list of methods that are
available. A method is an action, so
something that can happen. So does it have
a start method? Does it have a stop
method? Once we've identified that, then
we can get the name for that which won't
come back a start and stop unless that's
what the service has in this example. The
Windows Update service has a stop services
and start services. So I can then execute
a start and stop on. What's powerful here
is that this is being done from my machine
to a remote computer or it could be done
locally. So I can now retrieve information
about a service, check the methods to make
sure I can do an action and then start or
stop or perform the relative action that's required