Select Object/s and sort by parameters

This topic contains 1 reply, has 2 voices, and was last updated by  Daniel Krebs 2 years, 3 months ago.

  • Author
    Posts
  • #25983

    Bryan
    Participant

    Greetings.

    Not only is this my first question in this forum but this is also my first post. I hope being part of this forum would help me a lot in improving my skills in PowerShell.

    My first question:

    How do I exclusively display values based on numeral value? I'm practicing the comand " get-process " so I get something like

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
    ——- —— —– —– —– —— — ———–
    54 7 1356 5748 58 0.03 1100 conhost
    56 7 2184 8236 60 8.99 1264 conhost
    34 4 964 2916 43 0.00 1996 conhost
    310 10 1836 3780 42 340 csrss
    313 23 6084 10428 78 380 csrss
    169 20 135096 44904 225 59.81 2160 dwm
    815 56 48432 79816 310 23.01 2184 explorer
    818 93 314196 339504 664 277.37 2608 firefox

    I know how to display whatever column like " get-process | select-object handles/ProcessName/Id.

    How do you enter the required parameters to display what you want like, handles less than 500, or ProcessNames that end with the letter "t"?

    Also, is there a command to display an array(in its true form)? A command that would show you that get-process is written as $process = @{handles = "..."; id = "...."}

    I apologise if asking a lot of simple questions from here is annoying but I'm very keen to learn improve in PS and I'm really new to it. Thanks.

  • #25984

    Daniel Krebs
    Moderator

    Hi Bryan,

    Welcome to the amazing world of Windows PowerShell.

    Depending on how you like to learn (reading or watching):
    – Invest and buy the book "Learn PowerShell 3 in a Month of Lunches (2nd ed.)" and study the basics, and advanced PowerShell concepts.
    – Watch the awesome training video series "Getting Started with PowerShell 3.0 Jump Start" in the Microsoft Virtual Academy – https://www.microsoftvirtualacademy.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276

    Handle count lower than (-lt):

    Get-Process | Where-Object { $_.Handles -lt 500 } | Select-Object -Property Handles, ProcessName, Id
    

    Process name ends with t:

    Get-Process | Where-Object { $_.ProcessName -like '*t' } | Select-Object -Property Handles, ProcessName, Id
    

    Get online help for Where-Object and navigate to the examples at the end of the page:

    Get-Help Where-Object -Online
    

    Best,
    Daniel

You must be logged in to reply to this topic.