Filter syntax Powershell

De Linuxmemo.

  • comparison operator
   -ne (not equal to)
   -lt (less than)
   -le (less than or equal to)
   -gt (greater than)
   -ge (greater than or equal to)
   -like (like—a wildcard comparison)
   -notlike (not like—a wildcard comparison)
   -contains (contains the specified value)
   -notcontains (doesn't contain the specified value)
  • logical operators
   -and (The script block evaluates to True if the expressions on both sides of the logical operator evaluate to True.)
   -or (The script block evaluates to True when one of the expressions on either side of the logical operator evaluates to True.)
   -xor (The script block evaluates to True when one of the expressions on either side of the logical operator evaluates to True and the other expression evaluates to False.)
   -not or ! (Negates, or reverses, the script element that follows it.)


Paramètre "-Filter"

Get-ADComputer -filter {name -like '$nameregex'   -and Enabled -eq "true" }

Where-Object

Get-Command | Where-Object {$_.CommandType -eq 'cmdlet'}
Get-Command | Where-Object {($_.Name -like '*clear*') -and ($_.CommandType -eq 'cmdlet')}
Get-Command | Where-Object {($_.Name -like '*clear*') -and !($_.CommandType -eq 'cmdlet')}
Outils personnels