Learning Powershell - Basic Question about Searching

Hello All,

I have began the Powershell in a Month of Lunches book recently and I really look forward to answering my own PS questions in the future! I have a pretty noob question that I was hoping someone could point me in the right direction of.

I am currently doing the 3rd chapter on navigating the help file and learning how to read the documentation. One of the questions was about searching for the command you are looking for.

If I am trying to find an Alias that relates to Process, I was trying this:

Get-Alias -Name *location

But it does not return what I was looking for. If I try:

Get-Alias -Name gps

CommandType Name Version Source


Alias gps -> Get-Process

It returns the process, is there a way I can search for any of the text in the string?

Thanks!

[quote quote=247714]If I am trying to find an Alias that relates to Process, I was trying this:

Get-Alias -Name *location[/quote]

I wonder why you would look for “location” when you’re actually searching for “process”!? :wink:

You can search the the definition part like this:

Get-Alias -Definition *location*
#or
Get-Alias -Definition *process*

Thanks Olaf!

Oh yea, that would matter eh? :slight_smile:

Ah, so it is Definition and not Name I needed to look thru. In the results of Get-Process it lists it all under Name, Typically that would be the parameter name as well?

I cannot follow. Can you elaborate a little more detailed? What do you mean?

My apologies, my nomenclature is likely not correct! In the column headings in the image below, I was expecting the title of the column “Name” would be the parameter that could be “searched”.

screenclip

Ah … ok. Well you could search in the name property but only in the part before the “arrow” - so would search for the actual alias not for the cmdlet the alias stands for.

As you can see here: Get-Alias | Select-Object -Property Name,Definition what you see when you run the cmdlet with its default is actually not the “real” values of the name property. It is combined to get a better overview.

When Get-Alias, like many other commands, outputs in table format, sometimes PowerShell applies additional formatting to the output. This means that the column headers you see aren’t necessarily the actual property names. If you run Get-Alias gc | Format-List *, you will see that the post-formatted tabular Name is actually DisplayName. You can read more at About_Format