Where-Object - Powershell 3.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 pa ssed to it. For example you can use the Where-Object cmdlet to select files that were created after a certain date, eve nts 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. Whe re-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 t he 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 s tatements 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 equiv alent 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. Un less specified, all operators are case-insensitive. Prior to Windows PowerShell 3.0, the comparison operators in the Wi ndows PowerShell language could be used only in script blocks.