Up to this point, you’ve been working with whatever output the shell gave you: all the processes, filesystem objects, and various Azure commands. But this type of output isn’t always going to be what you want. Often you’ll want to narrow down the results to a few items that specifically interest you, such as getting processes or files that match a pattern. That’s what you’ll learn to do in this chapter.
The shell offers two broad models for narrowing results, and they’re both referred to as filtering. In the first model, you try to instruct the cmdlet that’s retrieving information for you to retrieve only what you’ve specified. In the second model (discussed in section 12.5), which takes an iterative approach, you take everything the cmdlet gives you and use a second cmdlet to filter out the things you don’t want.
Ideally, you’ll use the first model, which we call filter left, as much as possible. It may be as simple as telling the cmdlet what you’re after. For example, with Get-Process, you can tell it which process names you want:
Get-Process -Name p*,*s*