PowerShell by Patrik

Where-Object cmdlet in PowerShell

Selects objects from a collection based on their property values.

Where-Object
     [-InputObject <PSObject>]
     [-Property] <String>
     [[-Value] <Object>]
     [-EQ]
     [<CommonParameters>]

The Where-Object cmdlet selects objects that have particular property values from the collection of objects that are passed to it. For example, you can use the Where-Object cmdlet to select files that were created after a certain date, events with a particular ID, or computers that use a particular version of Windows.

Example 1: Get stopped services

Get-Service | Where-Object {$_.Status -eq "Stopped"}
Get-Service | where Status -eq "Stopped"

Where-Object (Microsoft.PowerShell.Core) - PowerShell | Microsoft Docs

PowerShell
Where-Object

Comments