Resource Management Powershell
Documentation Home
  • Home
  • Installation
    • Installing the PowerShell module
  • Configuration
    • Configuration management
    • ConfigSync File
    • Variables File
      • <Variables> element
        • <Variable> element
    • <Operations> element
      • <ResourceOperation> element
      • <AnchorAttributes> element
      • <AnchorAttribute> element
      • <AttributeOperations> element
        • <AttributeOperation> element
    • Building references
  • Usage
    • Cmdlet reference
      • Set-ResourceManagementClient
      • Get-Resource
      • Save-Resource
      • Search-Resources
      • Search-ResourcesPaged
      • Remove-Resource
      • New-Resource
      • Update-ResourceManagementClientSchema
      • Import-RMConfig
      • New-XPathQuery
      • New-XPathQueryGroup
      • New-XPathExpression
      • Get-ApprovalRequest
      • Set-PendingApprovalRequest
  • help and support
    • Quick reference guide
    • Working with different data and attribute types
    • XPath expression examples
Powered by GitBook
On this page
  • Description
  • Syntax
  • Parameters
  • Examples
  1. Usage
  2. Cmdlet reference

New-XPathQueryGroup

PreviousNew-XPathQueryNextNew-XPathExpression

Last updated 2 years ago

Description

The New-XPathQueryGroup cmdlet create a new group of query objects that can be used to create an XPath expression using , or an element in an XPath query group using . The resulting can be passed as a parameter to . An XPath query group contains one or more objects or other XPathQueryGroup objects.

Syntax

New-XpathQueryGroup [-Operator] <GroupOperator> {And | Or} [[-Queries] <IXPathQueryObject[]>]  

Parameters

Operator

Required. Specifies the logical operator to use when comparing queries within the group. The support values are And and Or

Queries

Required. One or more query objects generated with the or cmdlets

Examples

Viewing the query group string

The New-XPathQueryGroup does not return a usable query itself. It returns only a part of the query that is used in an XPath expression. You can view the query component itself as shown in the following example.

$query1 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan"
$query2 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "bob"
$queryGroup = New-XPathQueryGroup -Operator Or -Queries @($query1, $query2)
$queryGroup .ToString()

This returns an string representing the query component

((AccountName = 'ryan') or (AccountName = 'bob'))

Building a simple query

In order to use the query, it must be rendered by an XPath expression created with the [[New-XPathExpression]] cmdlet

$query1 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan"
$query2 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "bob"
$queryGroup = New-XPathQueryGroup -Operator Or -Queries ($query1, $query2)
$expression = New-XPathExpression -ObjectType "Person" -QueryObject $queryGroup 
$expression.ToString()

This returns an expression containing the query

/Person[((AccountName = 'ryan') or (AccountName = 'bob'))]

Building a nested query

A query group can contain other groups as well as standard queries.

$query1 = New-XPathQuery -AttributeName "DisplayName" -Operator StartsWith -Value "ryan"
$query2 = New-XPathQuery -AttributeName "DisplayName" -Operator Equals -Value "bob"
# Create the child group
$queryGroup1 = New-XPathQueryGroup -Operator Or -Queries @($query1, $query2)
$query3 = New-XPathQuery -AttributeName "Email" -Operator IsPresent
# Create the parent group using the child group and another query
$queryGroup2 = New-XPathQueryGroup -Operator And -Queries @($query3, $queryGroup1)
$expression = New-XPathExpression -ObjectType "Person" -QueryObject $queryGroup2
$expression.ToString()

The expression generated is as follows

/Person[((starts-with(Email, '%')) and ((starts-with(DisplayName, 'ryan')) or (DisplayName = 'bob')))]
New-XPathExpression
New-XPathQueryGroup
XPathExpression
Search-Resources
Xpath query
New-XPathQuery
New-XPathQueryGroup