Measuring statistics of multiple properties (emulate SQL group by)
The
-property
option allows to specify the properties for which a set of statistical values should be returned. Such a set somewhat corresponds to a record that is returned by an
SQL group by
operation:
get-process | measure-object `
-property workingSet,PagedMemorySize64,VirtualMemorySize64 `
-minimum -maximum -average -sum
#
# Count : 437
# Average : 32798031.0846682
# Sum : 14332739584
# Maximum : 1850437632
# Minimum : 8192
# StandardDeviation :
# Property : WorkingSet
#
# Count : 437
# Average : 38320076.4485126
# Sum : 16745873408
# Maximum : 1188343808
# Minimum : 57344
# StandardDeviation :
# Property : PagedMemorySize64
#
# Count : 437
# Average : 1146566214653.66
# Sum : 501049435803648
# Maximum : 2238949216256
# Minimum : 8192
# StandardDeviation :
# Property : VirtualMemorySize64
Select maximum value of a computation
The following example selects the maximum length of the txt
properties that are passed to the cmdlet.
This example does not work on PowerShell 5.1 or below.
[psCustomObject] @{ nm = 99; txt = "ninety-nine" } ,
[psCustomObject] @{ nm = 42; txt = "hello, world"} ,
[psCustomObject] @{ nm = 0; txt = "zero" } |
measure-object -property { $_.txt.length } -maximum |
select-object maximum