As a quick review, there are two primary ways to find PowerShell commands.
You can use the Get‑Command cmdlet.
Remember, a cmdlet is just the fancy name for a compiled PowerShell command.
I'll probably use cmdlet and command interchangeably,
but they really mean the same thing.
You can also use the Get‑Help command,
which has the added benefit of showing you how to run the command.
I'll get into these a bit later in the demos.
PowerShell has a few command types or categories.
The primary unit of execution is called a cmdlet.
Now, as the name implies, think little command.
Cmdlets are designed to do one small thing like stop a
service or create a virtual machine.
These are compiled programs, which means you can't view the source,
although PowerShell is now open source, so if you have some C# skills,
you can browse through the source files on GitHub.
All you have to know is that when you see the word
cmdlet that you know what that means.
A function is very similar to a cmdlet.
Often you can't really tell if you're running a cmdlet or a function,
and it really doesn't matter.
Almost all functions are written in PowerShell scripting language,
and you can easily view the source.
Eventually, you'll learn to create your own PowerShell functions.
For our purposes,
I'll refer to functions and cmdlets generally as PowerShell commands.
Another type of command is script.
This is a text file written with a ps1 file extension,
and it's written using PowerShell scripting language.
At its simplest, it is really nothing more than a fancy batch file.
Instead of typing commands interactively,
you can put them in the script file and just run the script.
Of course, there's a lot more that you can do with scripting,
but that's a whole other course.
The last command definition is application.
Now this is typically any program or executable that's found in
your system path like notepad.exe or ipconfig.
In fact,
you can run almost any command‑line tool from a PowerShell
prompt. Feel you need to use the netstat command? Even though
there is a powerful equivalent,
you can keep running netstat just like you always have.
Now, as a transition to PowerShell, you can take this further.
You can still run your batch and VBScript files right from a PowerShell
prompt. Need to run something like Python or Ruby? No problem.
If you can run it at a C prompt,
you can most likely run it in PowerShell. One of the reasons
that PowerShell is easy to learn, trust me,
it really is, is because PowerShell commands follow
a standard naming convention.
Remember, commands mean cmdlets and functions.
PowerShell scripts can have whatever name you want to give them.
PowerShell commands are supposed to follow a verb‑noun naming pattern.
The noun is the singular version of the thing that the cmdlet is working with,
like file, service, or ACL. The verb comes from a list of standard .NET verbs,
most of which are pretty basic like get, set, and remove.
Now PowerShell has a command called Get‑Verb,
which will do exactly what the name suggests.
It will get a verb, although, as you'll see,
it's pretty simple to get all of the verbs at the same time.
Now, let me point out that this naming convention is not a hard and fast rule.
It is possible for someone to make a PowerShell command
called something like Erase‑Files.
That name does not follow the rules.
Fortunately, the PowerShell team at Microsoft does follow the naming guidelines,
and a lot of other people who make cmdlets do follow those rules, so it is much
easier to find or even guess the name of commands because of this naming
convention. There is another way commands can be called,
and that is by an alias.
Now,
an alias is technically nothing more than an alternate name for a
command. Under the hood and technically speaking,
this is just another command type to go along with function and cmdlet.
But aliases tend to be easier to use.
They're often shorter, which means less typing,
which a lot of people like. Aliases often exist also as transition tools.
For example, in PowerShell, you can use the dir command to list files,
just as you did from a dos or cmd prompt.
But you aren't really running the dir command.
You are running a PowerShell command called Get‑ChildItem.
Using the dir alias makes things a little bit easier for you till
you learn the PowerShell way to list files.
How do you think you could get a list of aliases in PowerShell?
Well, yeah, it's really that easy, and I'll cover all of this and more a little bit later in the demonstrations.