So let's go back into PowerShell,
and let's look at a few more examples to reinforce the
information that I've given you here in these slides.
Alright, so let's begin, and let's just run help again for Get‑Service,
just make sure this also works here.
Alright, so it's same information that we saw before.
And again, I can do help Get‑Service.
If I want to look at the parameter name,
I can see some details about that parameter.
We covered this little bit in the slides.
But knowing that, I should be able to run a command like Get‑Service,
and I see everything.
I didn't specify ‑Name or any other of the parameters
because I didn't really need to.
We're going to come back,
and we're going to look at the name parameter in a little more
detail because that is kind of the default,
but this command is designed to really not need anything.
It assumes if I run Get‑Service without specifying anything,
it's going to give me all of the services.
However, if I wanted to, I could do this.
I could say find me all the services where the name is bits, winrm, or winmgmt.
Now I'm using the ‑Name parameter, and I get just those services.
How about this?
Let's do Get‑Service bits, winrm, winmgmt.
That also works.
Now the difference is I did not use the ‑Name parameter.
That's because ‑Name is positional.
Let's look at another example here.
Let's do bits, and then win*, and we're going too
pipe those strings to Get‑Service.
Hey, look at that.
So there's bits, and then because there's a wildcard,
I get all of the services that start with win.
If I want to review why that is,
I could look at help for Get‑Service, so look at that Name
parameter. Now we can see there a couple things. Again, reminder,
this takes strings, and see the double square brackets, that means
it can take multiple strings, which, as you saw,
that's what I did in my demo.
It's not required,
and we saw that because I can just run Get‑Service, and it works.
I don't have to type the name of the parameter, ‑Name, because it
is positional, and you see it has position 0.
There is no default value.
It will accept pipeline input by proper name and by value. Value means, hey,
whenever I see like strings, I'm going to assign them to the parameter
‑Name. ByPropertyName, I'll just give you a little heads up, you'll learn
more about this later, ByPropertyName means if I see an object coming in
that has a parameter, I'm sorry, if I see an object coming in that has a
property name that matches the parameter name, then I'm going to hook
those two values together and magic happens, which is a really a wonderful
thing.
I have another demo coming up where you'll see how that works.
And you can also see here from the help that it accepts wildcard characters,
and I proved that by using win*. You can run the command, and help will help
you decide how to run it, or at least reinforce or make sure you understand why it's working the way that it does.