New-XPathQuery
Description
The New-XPathQuery
cmdlet create a new query object that can be used to create an XPath expression using [New-XPathExpression], or an element in an XPath query group using New-XPathQueryGroup. The resulting XPathExpression can be passed as a parameter to Search-Resources. An XPath query object contains the component of an expression that compares an attribute with a value.
For a list of examples filters generated by the XPath cmdlets, see the XPath expression examples page.
Syntax
Parameters
AttributeName
Required. The name of the attribute to compare
Operator
Required. The operator to apply to the attribute
Value
Optional if using the IsPresent or IsNotPresentOperator. Required for all other operators. The value to use in the comparison. This can be any value that can be converted to the data type of the attribute being searched. Reference attributes can also specify another XPath expression as the search value. See the dereferencing example below.
Negate
Optional. Negates the expression by inverting the comparison operation. For example, using the Negate
switch, the LessThan operator becomes not LessThan. Note that the FIM XPath dialect does not support double negation. Therefore using the Negate
parameter on IsNotPresent and NotEquals operators is not supported.
Examples
Viewing the query string
The New-XPathQuery
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.
This returns an string representing the query component
Building a simple query
In order to use the query, it must be rendered by an XPath expression created with the [New-XPathExpression] cmdlet
This returns an expression containing the query
You can also use the pipeline to pass the query to the [New-XPathExpression] cmdlet.
Testing for presence
The IsPresent and IsNotPresent operators work without the Value
parameter
This returns an expression containing the query
Using another XPath expression to query a reference attribute
This returns an expression containing the query
Last updated