[Autogenerated] So now that we've looked
at how to review and see the same classes
and the commands, how do we execute
commands using Sim? Well, first off, Sim
commands are based on verbs, just like
they would be with anything. In
PowerShell, we have the get command, the
invoke command, the new command we can
register something we can remove something
or set something. So just like most common
PowerShell commands, they are prefixed
with a verb. So what are the common Sim
commands that we would utilize? Well,
firstly, get Sim instantiate one of the
most common. This will get you the SIM
instances off a class from the same
server. What I mean by the same server is
just the server or the workstation that
you're connected to. New SIM session will
create us a remote session or a SIM
session to the machine that we've
targeted. Then, of course, we have invoked
SIM method which will allow us to invoke
any methods that are associated to a
class. So, for example, if we did win 32
underscore process as the class, we know
that when we retrieve the processes,
we can filter to a specific one. So, for
example, note pad, nor XY. There's also
methods associate ID to that, such as
start, stop, etcetera. So we're able to
invoke the methods. So let's look at the
get Sim instance. The first option we have
is we can query all sim instances by using
the select kind of syntax. So we can
either use a query command or we can. Use
a filter. Cmdlet there will work. If we
use Query, it's a select star from
whatever the class would be, and then
whatever the query would bay. So in this
instance, it's going to get me all the
instances that start with the letter P in
the process class. We could also do the
same by just filtering it to the class
name on, then saying IFilter by specifics.
Now both of these will retrieve the same
values but just be filtered differently.
The next option is we could actually say
retrieve specific properties using that
same instance. So by default, when we
retrieve a sim instantiate were normally
just saying, Get me the class name, maybe
we're filtering, but this way we could
actually get the properties that we would
need. Now, think about this when I say get
Sim instance, and query, I'm literally
just getting the actual class itself. So
there were times where you might want to
get the specific value. So in this example
here I'm using the property value and
saying, Get me the name of the process on
the kernel mode time So the time it's been
executing I can, then retrieve it as a
static kind of list or I can use standard.
PowerShell cmdlet is such as formatted as
a table, etcetera. So let's look at the
new SIM session so we can create a SIM
session just with all the standard
defaults by just saying New SIM session on
that will just create a SIM session that
we need. What we can do is we can create
remote sessions to specific computer
names, and then we can assign a name to
them. So in this instance, even though I'm
connecting to the local host, it would
technically be classed as a remote
connection because I'm not just allowing
the same session to use its default
options. I've specified the computer name
on the name that I would like to assign to
that session. We can also pass credential.
So if you're trying to connect to a
different device. So let's say I want to
connect to a different server or a
different workstation. Then you can pass
credentials using standard get credential
and then new SIM session computer name,
pass the credentials and then the
authentication type, which in this
instance will be negotiate. Now, what
about if we want to invoke a method well,
firstly, we can use invoke sim method and
notice what we're doing here. We're
querying for a specific process, and then
that means we would need to know what the
method name is so that we can do
something. So, for example, I could say
select star from 1 30 to where the name is
like note pad or cmd on then I can either
start, stop, terminate or restart or
whatever the methods that would be
available. So you do need to know what the
methods are are. Before you could execute
this command. Now we could do the same
thing by running a process with specific
arguments. So where where we can do this
is we can use invokes in method. Get the
class the method name. Remember, The key
here is knowing what the method names are,
which in this instance would be create
because I want to create a new instance
off that one, and then we can use
arguments and then we can basically do
like key value pairs. So we can say the
command line is equal to cmd do XY on the
current directory is so and so what that
means is it will launch that process
because we told it to create with those
arguments associated to it. So this is
really powerful because it means that when
we scripting things, maybe a full on
PowerShell script that does X y Zed tasks,
then we can actually pass things like this into it to do things for us.