New-CMRequirementRuleExpression

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

Syntax

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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:ExpressionBase[]
Aliases:AddExpressions
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AddRequirementRule

-ClauseOperator

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

Type:ConnectOperator
Accepted values:And, Or
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisableWildcardHandling

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

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

-ForceWildcardHandling

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

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

-GroupOperator

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

Type:ConnectOperator
Accepted values:And, Or
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

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

Inputs

None

Outputs

System.Object