liveBook · Manning

Filtering

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Filtering is the technique of selecting values or objects that satisfy specified criteria and excluding the rest.

Filtering narrows shell results to the processes, files, or other objects that match a useful criterion instead of displaying everything retrieved. section 12.0

PowerShell provides two practical filtering approaches:

  • Filter left: ask the retrieving cmdlet for matching objects, keeping filtering close to the data source and reducing later work. section 12.1 section 12.6.1
  • Filter in the pipeline: pass retrieved objects to Where-Object, which evaluates each object and drops those whose comparison is False. section 12.1 section 12.4

Keep processes using more than 100 MB

Get-Process | Where-Object {$_.WorkingSet -gt 100MB}. The $_ placeholder represents the current process, and WorkingSet identifies the property being compared. Verify property names with Get-Member rather than relying on displayed column headings. section 12.4

Get-Process -Name p*,*s*

Try filtering process names directly with Get-Process -Name p*,*s*. section 12.1

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains early and pipeline filtering, comparisons, $_, property names, and source-side placement.
Examples
Uses process-name wildcards and WorkingSet comparisons, including combined CPU and memory conditions.
What you can do after
Apply it via PowerShell cmdlets and Where-Object to select matching objects and reduce downstream pipeline work.
How it connects
Connects filtering with comparisons, pipelines, Get-Member, cmdlets, and PowerShell remoting.

Also explained in

Compare how 33 books explain filtering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.