Creating Dynamic Resource and Target Groups
Last updated on February 12, 2021.
Last Reviewed and Approved on PENDING REVIEW
Dynamic Groups allows you to add filter conditions to a group. Then any Resource or Target that matches the conditions will be automatically added to those groups.
Use Cases
- Create a Target Group of Windows Machines by filtering on OsType = 'Windows'. Then you can assign a Resource Item to all Windows machines.
- Create a Resource Group of Admin Accounts where Role Contains 'Admin'.
Steps
$condition1 = New-RpsGroupCondition -ConditionOperator "Eq" -Property "Type" -Value "VirtualMachine"
$condition2 = New-RpsGroupCondition -ConditionOperator "Contains" -Property "Role" -Value "RpsAdmin" -Delimiter "|"
New-RpsResourceGroup -Name DynamicGroup1 -Type DynamicGroup -Operator "And" -Condition $condition1, $condition2
The first command New-RpsGroupCondition
describes the condition. This uses the same syntax as
PowerShell Operators.
We support strings, booleans, integers, containments, and regex comparisons. If a property on an entity is an array, then you can supply the delimiter value to split the string into an array.
New-RpsResourceGroup
and New-RpsTargetGroup
have two new additional fields.
- "Conditions", which takes a list of the conditions object created above.
"Operator", with values 'And' or 'Or'.
Note
The operator value 'And' says all conditions must match; 'Or' says only one condition must match.