Skip to main content

Filter Condition Sets

Filter Condition Sets group together a set of Filter Conditions. This is designed to help prevent invalid combinations (IsBeer -and OSWindows does not make much sense) and also as a way to select just which version of a Condition is used for a given Filter Expression.

Essentially, any actual Filter Expression is evaluated by a Condition Set and all Conditions used in that Expression must be included in that set.

End-to-End Examples

The examples here focus on just defining a single condition. For simple hands-on examples that show how it all works together, see the End-to-End examples page.

Examples

Predefined Conditions

$conditions = Get-PSFFilterCondition -Module Bartender
New-PSFFilterConditionSet -Module Bartender -Name Alcohols -Conditions $conditions

Creates a new filter condition set "Alcohols" for the module "Bartender", including all conditions defined so far.

Define Conditions together with the Condition Set

New-PSFFilterConditionSet -Module 'Bartender' -Name 'Alcohols' -ScriptBlock {
New-PSFFilterCondition -Module Bartender -Name Beer -ScriptBlock { $_.Type -eq 'Beer' }
New-PSFFilterCondition -Module Bartender -Name Vodka -ScriptBlock { $_.Type -eq 'Vodka' }
New-PSFFilterCondition -Module Bartender -Name Whiskey -ScriptBlock { $_.Type -eq 'Whiskey' }
New-PSFFilterCondition -Module Bartender -Name Rum -ScriptBlock { $_.Type -eq 'Rum' }
}

Similar to the first example, this defines the Condition Set "Alcohols" for the module "Bartender". In opposite to the last example, this time we define the Filter Conditions together with the set.