How to get value a value of a variable returned by the select function

Joe 96 Reputation points
2021-03-03T17:17:33.74+00:00

Hi, Newbie question here: How do I get the value of of the PM Object itself?

Get-Process -Name powershell_ise | Select-Object PM

PM
-- 153763840

Thanks Joe

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,429 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 45,416 Reputation points
    2021-03-03T19:35:43.7+00:00

    The "Select-Object" returns a PSCustomObject that has a TypeName of Selected.System.Diagnostics.Process, and that has "NoteProperty" attributes that act as hash tables (in this case) that have a name (in this case PM) and a definition (in this case "long PM=202792960").

    You can get the value of that NoteProperty like this:

    (Get-Process "powershell_ise" | Select-Object PM).pm
    

    Or, like this to just return return the value of the PM (which is an alias for the actual property "PagedMemorySize64"):

    Get-Process "powershell_ise" | Select-Object -ExpandProperty  PM
    

    I'd suggest that you visit this URL (Windows-PowerShell-4) and download the free copy of the book. It's written in easily digestible chapters and you learn a lot be reading just the 1st half.

    0 comments No comments