And with that,
let's get back into PowerShell and let me demonstrate how
you can discover what you can do with it.
I often tell people that I don't train people in PowerShell, I teach them.
Training implies that you have to learn a certain way to achieve a task.
Click here, type that, press this button.
PowerShell isn't like that.
I need to teach you how PowerShell works and how you can
continue to teach yourself so that you can continue to learn
PowerShell long after our class is over.
But enough of that, let's get into PowerShell. Alright,
so back in PowerShell and I have a prompt open, and
let's just look at this Get‑Command.
Let's run Get‑Command, and if I hit Enter by itself,
this is going to go through and find all of the commands
that PowerShell knows about on my computer.
Your list, obviously, will look different than what I might have here.
Now I'm going to do something a little bit different here,
I'm going to do Get‑Command, and the thing I'm going to
look for is a vegetable object.
This is just kind of a placeholder,
something I've built for myself for teaching so that you don't get bogged down
on technical details, you can just focus on the concepts.
So I've told PowerShell, hey, I need to do something with vegetables.
What commands do you know about so I can do Get‑Command and then some
wildcard around the thing that I want, vegetable So I can see that
PowerShell knows about commands such as Get‑Vegetable,
New‑Vegetable or Set‑Vegetable. Notice they follow
that Verb‑Noun naming convention.
So once you understand how that pattern works,
then we can try it with real commands, like say services.
I did a wildcard around *service*, so I get a lot of things. And maybe I
want to refine that. So let's do Get‑Command *service,
no wildcard at the end of that, now I get a much more manageable
list. This is probably really what I was looking for.
Get‑Command also has this option to work with verbs, so say hey,
tell me everything that you know about that I can get. Again, it's going to be a
pretty long list. Now how did I know Get was a verb other than seeing it there
in the list? Well, there is the command Get‑Verb,
which I mentioned to you before,
and this will show you all of the possible verbs that
you can find in a PowerShell command.
When you get to scripting,
you'll be using these same verbs for your own commands.
So once you see what those verbs are,
then it becomes easier to discover what it is that you can do.
So I know one of the verbs is Stop, so let's do
Get‑Command and look for all the Stop commands.
There we go, really, you know, quite a few. Nouns work kind of the same way.
Let's go back to my vegetable idea.
Let's say I don't know the full name of the thing that's a
vegetable, maybe it's vegetable foo or something else, so
I'll just use the wildcard.
So we'll do veg*, and then I get my commands.
Once we know the pattern, now we can do it with real things such as,
say, processes, or something with process in the name.
And again, we may want to fine tune that list.
As I said in the slides,
we can also combine these things and I can combine the noun and the verb to say
find me all of the commands that start with re, like remove,
replace, or whatever, and then share is some part of the noun. And there we go.
So now I have found some other commands that I can work with that meet the criteria that I was looking for.