Where-Object - Powershell 4.0 CmdLet
ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »
Where-Object
Short description Selects objects from a collection based on their property values. Syntax Description 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 with a particular version of Windows. Beginning in Windows PowerShell 3.0, there are two different ways to construct a Where-Object command. Script block. You can use a script block to specify the property name, a comparison operator, and a property value. Where-Object returns all objects for which the script block statement is true. For example, the following command gets processes in the Normal priority class, that is, processes where the value of the PriorityClass property equals "Normal". Get-Process | Where-Object {$_.PriorityClass -eq "Normal"} All Windows PowerShell comparison operators are valid in the script block format. For more information about comparison operators, see about_Comparison_Operators (http://go.microsoft.com/fwlink/?LinkID=113217). Comparison statement. You can also write a comparison statement, which is much more like natural language. Comparison statements were introduced in Windows PowerShell 3.0. For example, the following commands also get processes that have a priority class of "Normal". These commands are equivalent and can be used interchangeably. Get-Process | Where-Object -Property PriorityClass -eq -Value "Normal" Get-Process | Where-Object PriorityClass -eq "Normal" Beginning in Windows PowerShell 3.0, Where-Object adds comparison operators as parameters in a Where-Object command. Unless specified, all operators are case-insensitive. Prior to Windows PowerShell 3.0, the comparison operators in the Windows PowerShell language could be used only in script blocks.