Where statement

Filter objects from the pipeline, based on object properties.

      command | Where{test1 [conjunction test2] 

   conjunction  Any of the following: (logical boolean operators) 
          -and, -or (Logical or), -bor (Bitwise or), -band (Bitwise and), -xor 

   Test1   An expression that resolves to a Boolean (TRUE/FALSE) value.

   Test2   An expression that resolves to a Boolean (TRUE/FALSE) value.
   comparison operators

The expression can use any of the PowerShell comparison operators as long as the result is a boolean.
Also: -not logical Not (with ! as an alias) and -xor (Exclusive OR)

In addition to the Where statement, there is an built in alias Where for the Where-Object command . If you are unsure whether to use a statement or a command, just use Where and PowerShell will choose.


Lists files on drive f: greater than 1000000 bytes:

PS C:\>Get-ChildItem f:\ | where {$_.Length -gt 1000000}

“The enemy of art is the absence of limitations” ~ Orson Welles


Where-Object - Filter input from the pipeline (Alias = where)

© Copyright SS64.com 1999-2013
Some rights reserved