Skip to content

Test-Condition

SYNOPSIS

Evaluate whether a feature flag rule applies.

SYNTAX

Test-Condition [-Context] <Hashtable> [-PropertySet] <PropertySet> [-Condition] <Condition>
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Takes the given context, properties, and rule/condition and evaluates whether the rule applies and what it's effect is.

EXAMPLES

EXAMPLE 1

$propertySet = Get-PropertySet -Name props
$rule = New-Rule -Name 'MyRule' -Conditions @{
    AllOf = @(
        @{ Property = 'Hostname'; Operator = 'Equals'; Value = $env:COMPUTERNAME }
    )
}
$context = New-Context -PropertySet $propertySet
$context.Hostname = $env:COMPUTERNAME
Test-Condition -Context $context -PropertySet $propertySet -Condition $rule

This would return a true/false

PARAMETERS

-Context

The device context.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PropertySet

The PropertySet that matches given context.

Type: PropertySet
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Condition

A condition to test which are part of rules.

Type: Condition
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Boolean

Returns $true if the condition matches the given context, $false otherwise.

NOTES