9872
9872

Reputation: 3

Can not get where-object & -gt to work together

I'm simply trying to filter out the variables of the "PeakWorkingSetSize" process so that the output will ONLY be greater than 5000. No matter what combination I try, the numbers won't filter. Please help.

get-wmiobject -class Win32_Process | where-object {$_.PeakWorkingSetSize -gt "5000"} | format-table -auto

FIXED thanks to @Matt!

I actually still don't know what the problem was. XD Here is the code that works:

get-wmiobject -class Win32_Process | where-object {$_.PeakWorkingSetSize -gt "5000" | format-table -property Name,PeakWorkingSetSize -auto

Upvotes: 0

Views: 317

Answers (1)

Matt
Matt

Reputation: 46710

There is nothing wrong with this query and it should run as you have it written. Format-Table would be making for some odd output size some of those properties do not translate to string very well. Your query and selecting some specific properties yields expected results for me. 5000 is a really low number though.

PS C:\Users\Matt> get-wmiobject -class Win32_Process | where-object {$_.PeakWorkingSetSize -gt "5000"} | select name,processid,peakworkingsetsize 

name                                   processid peakworkingsetsize
----                                   --------- ------------------
System                                         4              15588
csrss.exe                                    580              35412
csrss.exe                                    732              47356
services.exe                                 780              11820
winlogon.exe                                 812               8832
.... output truncated.....

If something is still wrong I think we need to see your expected output to understand what is wrong.

Upvotes: 1

Related Questions