Up until now, we've been working with
pre‑installed modules, and you understand
where they're located on your machine and
how to import them. But you'll also need
to know how to find which commands are
included inside of a module because, well,
the commands are what you'll be running
with to actually do tasks with PowerShell.
Let's dig into that. There's a handy
command to know about called Get‑Command.
If we run that with no parameters or
settings, it will go and list all of the
commands that exists in all of the modules
on this machine. Wow, that's a big list
and really not too helpful. There's a
parameter on Get‑Command named
ListImported. And if I run that, we'll get
a list of commands included only in
modules that have been imported into this
session. That's a much smaller list, but
it's still got a lot of information to go
through to find commands. Another option
with Get‑Command is to use the module
parameter to specify which PowerShell
module you want to list the commands for.
Let's try that out with Get‑Command
‑ModuleBitsTransfer. Ah, that's a bit more
digestible as we've been provided a list
of commands that are specific just to this
module so you can quickly see the type of
actions you can perform by leveraging this
module. Another way to see the commands
inside of a module, and you've seen this
before if you were watching closely, is to
run Get‑Module and the name of the module,
so BitsTransfer. And this ExportedCommands
property lists the commands included in
the module. That's not really the best
view there, so what you can do is enclose
to Get‑Module command in parentheses
followed by a period, and we can look at
that ExportedCommands property. And that's
a bit nicer listed out that way as we can
see all the values. Note that this is the
same list as before when we did
Get‑Command. So there's a few different
ways to find all of the commands inside of
a module. Remembering the PowerShell
language standard of using verb‑noun for
command naming, another option we have is
to search only for commands with a
particular verb. Let's say, for example,
that I know I need to do something with
the bits transfer service, but all I want
to do is get some information. If I run
Get‑Command ‑Module BitsTransfer and then
use a verb parameter, and I'll specify get
as the verb, this will only return
commands from the module that have a verb
get, and there happens to be only one
command returned. This is a really nice
way to further filter down on commands
when you know what type of action you want
to take, but aren't sure exactly what the
command might be named, which is
particularly helpful in modules containing
lots of commands. Finally, you can also
perform wildcard searches with
Get‑Command. So let's assume I wanted to
do something with a file related to
BitsTransfer, but I didn't yet know what
that was. If I just press the up arrow to
get that command again, but at the end
instead of specifying the verb, I'll just
put *file*, which will perform a wildcard
search for any command with file in the
name. And again, we happen to only have
one result. But now I know really quickly
that there's only one command in this
module that might be related to the task I'm trying to perform.