Learning Powershell – Basic Question about Searching

Welcome Forums General PowerShell Q&A Learning Powershell – Basic Question about Searching

Viewing 6 reply threads
  • Author
    Posts
    • #247714
      Participant
      Topics: 4
      Replies: 6
      Points: 15
      Rank: Member

      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!

    • #247723
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

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

      Get-Alias -Name *location

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

      You can search the the definition part like this:

      [/crayon]
    • #247801
      Participant
      Topics: 4
      Replies: 6
      Points: 15
      Rank: Member

      Thanks Olaf!

      Oh yea, that would matter eh? 🙂

      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?

    • #247804
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      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?

    • #247810
      Participant
      Topics: 4
      Replies: 6
      Points: 15
      Rank: Member

      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

    • #247813
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      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.

    • #247846
      Participant
      Topics: 0
      Replies: 78
      Points: 348
      Helping Hand
      Rank: Contributor

      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

       

Viewing 6 reply threads
  • You must be logged in to reply to this topic.