This is beautiful, Thanks!
How to get value a value of a variable returned by the select function
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
1 additional answer
Sort by: Most helpful
-
Rich Matheisen 47,496 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.