Next, let's look at aliases.
Now in PowerShell,
you know that you can run the dir command to get a listing of files and folders.
If you're a Linux‑type person,
obviously you know you can also use the ls command. Works the same way.
Now what you're really though running is a
PowerShell command called get‑childitem.
The ls and dir commands are just aliases.
PowerShell commands also have a lot of aliases.
For example,
you may see code out there that uses what looks like a cryptic command,
gsv, but that's really just running Get‑Service.
The full command is Get‑Service.
Now, how did I know that Get‑Service and gsv are the same thing?
Well, you can use Get‑Command.
So if you see an alias like gsv, Get‑Command, the name of the alias.
It's clear, with that little representation of the arrow,
that gsv is resolving to Get‑Service.
And so if I then did Get‑Command Get‑Service,
I could see, oh, yep, it's a command,
and I see what version I'm running and the source of that.
Obviously, taking this to the next step then is to run Help
on Get‑Service so I can see how to use it.
And then you use the same parameters with the alias.
The alias is just an alternate name,
just like a criminal alias, also known as gsv.
Run gsv ‑Name, ‑DependentServices,
‑DisplayName the same way you would use it with Get‑Service.
In fact, you can also do help on the alias, and it will resolve.
So if I want to say, hey, how do I use the dir command,
such as it is in PowerShell, help dir will resolve to Get‑ChildItem,
and then all those parameters,
you can use them the same way that you would with Get‑ChildItem.
You can use it with the alias of dir or ls.
And if I want to find out what commands I can use with aliases,
hey, sure enough, ask PowerShell, what commands do you know with the alias noun?
And there are a number of them,
and I'll let you play with the help and see how to work with those and create your own aliases.