From the course: PowerShell 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filtering specific data

Filtering specific data - PowerShell Tutorial

From the course: PowerShell 5 Essential Training

Start my 1-month free trial

Filtering specific data

- Selecting properties, sorting properties, creating even our own custom properties, well, those are very useful things when working with all of the objects that we have, that we need to be able to work with as we're trying to fix problems or get information. But a lot of times I also want to filter the things I don't want to see out, so I don't see them. Let's take a simple example of I want to get a list of services, but I only want to see the ones that are stopped. So let me show you how we can do this. I'm gonna do get-service. We have a Cmdlet that'll let you filter called where-object. Now the interesting thing about where-object, and I'll show you, there's a parameter called FilterScript that has two curly braces. Inside of the curly braces is where you need to put the expression. Now, a couple of points. Before I put in an expression, I need to show you how we do comparisons in Powershell. It's different from a lot of other languages. The other thing I want to point out is…

Contents