Edit

Share via


New-CMRequirementRuleExpression

Create a requirement rule to evaluate a custom global condition with a complex expression.

Syntax

Default (Default)

New-CMRequirementRuleExpression
    [-AddAsGroup]
    [-AddExpression <ExpressionBase[]>]
    [-AddRequirementRule <Rule[]>]
    [-ClauseOperator <ConnectOperator>]
    [-GroupOperator <ConnectOperator>]
    [-RootExpression <ExpressionBase>]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [<CommonParameters>]

Description

Use this cmdlet to create a requirement rule on an application deployment type that evaluates a custom global condition with a complex expression. When you create a global condition, the Condition type needs to be Expression. These expressions let you add multiple clauses and group them with logical operators.

To create a custom global condition with an expression, use the New-CMGlobalConditionExpression cmdlet.

After you use the New-CMRequirementRuleExpression cmdlet, then use one of the Add- or Set- cmdlets for deployment types. Pass this requirement rule object to either the AddRequirement or RemoveRequirement parameters.

For more information, see Deployment type Requirements and Create global conditions.

Note

Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.

Examples

Example 1: Add a basic expression

$rule1 = Get-CMGlobalCondition -Name "Total physical memory" | New-CMRequirementRuleCommonValue -Value1 2048 -RuleOperator GreaterEquals
$myRuleExpression = New-CMRequirementRuleExpression -AddRequirementRule $rule1
$myGC = New-CMGlobalConditionExpression -Name "GCExp" -DeviceType Windows -RootExpression $myRuleExpression

Example 2: Add a complex global condition expression

$ruleProc = Get-CMGlobalCondition -Name "Number of processors" | New-CMRequirementRuleCommonValue -Value1 2 -RuleOperator GreaterEquals
$ruleMem1 = Get-CMGlobalCondition -Name "Total physical memory" | New-CMRequirementRuleCommonValue -Value1 2048 -RuleOperator GreaterThan
$ruleMem2 = Get-CMGlobalCondition -Name "Total physical memory" | New-CMRequirementRuleCommonValue -Value1 4096 -RuleOperator LessEquals
$ruleCPUSpeed1 = Get-CMGlobalCondition -Name "CPU Speed" | New-CMRequirementRuleCommonValue -Value1 5120 -RuleOperator LessEquals
$ruleCPUSpeed2 = Get-CMGlobalCondition -Name "CPU Speed" | New-CMRequirementRuleCommonValue -Value1 1024 -RuleOperator GreaterThan
$expressionProc = New-CMRequirementRuleExpression -AddRequirementRule $ruleProc
$expressionMem = New-CMRequirementRuleExpression -AddRequirementRule $ruleMem1, $ruleMem2 -ClauseOperator And
$expressionCPU = New-CMRequirementRuleExpression -AddRequirementRule $ruleCPUSpeed1, $ruleCPUSpeed2 -ClauseOperator And
$myRuleExpression = New-CMRequirementRuleExpression -RootExpression $expressionProc -AddExpression $expressionMem,$expressionCPU -ClauseOperator And -AddAsGroup -GroupOperator Or
$myGC = New-CMGlobalConditionExpression -Name "GCExp" -DeviceType Windows -RootExpression $myRuleExpression

Parameters

-AddAsGroup

Add this parameter to add the expressions as a group. Specify more than one expression with the AddExpression parameter. Use the GroupOperator parameter to specify the connector.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AddExpression

Specify one or more expression objects to add to a new expression. Create these objects with this same cmdlet. Use the RootExpression parameter to specify the first expression.

Parameter properties

Type:

ExpressionBase[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:AddExpressions

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AddRequirementRule

Specify an array of requirement objects for the expression. To create a requirement rule object, use one of the following cmdlets:

Parameter properties

Type:

Rule[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:AddRequirementRules

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ClauseOperator

Specify the logical operator to use as the connector between multiple expressions.

Parameter properties

Type:ConnectOperator
Default value:None
Accepted values:And, Or
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisableWildcardHandling

This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceWildcardHandling

This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-GroupOperator

Specify the logical operator to use as the connector between groups. Use this parameter with the AddAsGroup parameter.

Parameter properties

Type:ConnectOperator
Default value:None
Accepted values:And, Or
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RootExpression

Specify the first expression with this parameter. Create an expression object with this same cmdlet. To add more than one expression, also use the AddExpression parameter.

Parameter properties

Type:ExpressionBase
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

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

Inputs

None

Outputs

System.Object