question

Joe-1295 avatar image
0 Votes"
Joe-1295 asked ·

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

windows-server-powershell
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Joe-1295 avatar image
0 Votes"
Joe-1295 answered ·

This is beautiful, Thanks!

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

But your answer really isn't the answer, is it? :-)

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.