From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Filtering objects

Filtering objects

- [Instructor] Now, of course, it's all good and well being able to retrieve an item and then sort an item, et cetera, but what we mostly want to do is actually filter the information then we come back. Rarely do we need to say, "Go and get me everything" and never do anything with it. We tend to retrieve data because we are trying to then filter the data and identify something else in that content. So, it's kind of what we do in a SQL database where you say, select everything from the table where something is, whatever. So, what we can do is we can use the Where-Object command. So, in the Where-Object command, we have a construct to the Where-Object. And then, we have this object called $_. $_ is effectively whatever the item is right now. So if I say Get -Service, it retrieves me an object which is a full array of data. And then the $_ is going to be the object that represents that specific thing. And then, the properties that are available are available from the $_. and the list…

Contents