Search Resources

Ryan Newington edited this page Jul 9, 2016 · 2 revisions


The Search-Resources cmdlet allows you to perform a query for multiple objects from the FIM Service. By default, the cmdlet returns only the ObjectType, ObjectID, and DisplayName attributes for the objects matched by the query string. Use the ExpectedObjectClass or AttributesToGet parameters to control the attributes that are returned.


Search-Resources -Xpath <string | XPathExpression> [-ExpectedObjectClass <string>] [-MaxResults <int>] [-PageSize <int>] [-SortAttributes <string[]] [-Descending] [-Locale <string>]
Search-Resources -Xpath <string | XPathExpression> [-AttributesToGet <string[]>]  [-MaxResults <int>] [-PageSize <int>] [-SortAttributes <string[]] [-Descending] [-Locale <string>]
Search-Resources -Xpath <string | XPathExpression> [-Unconstrained]  [-MaxResults <int>] [-PageSize <int>] [-SortAttributes <string[]] [-Descending] [-Locale <string>]



The query to use in the search operation. This can be a string or an XPath expression created with the [New-XPathExpression] cmdlet


Optional. Specifies the expected object type that will be returned from the query. The client will use this to request the attributes from that class as part of the query.


Optional. A list of attributes to retrieve for the objects matching the search criteria


Optional. Performs an unconstrained query, allowing the FIM service to process all attributes in the schema when a matched object is found. This option should be used with caution as it causes significant performance impact on the FIM service.


Optional. Limits the number of results returned by the search operation.


Optional. Specifies how many results should be retrieved per page.


Optional. Specifies a list of attribute names used to order the results


Optional. Specifies that the sort attributes should be sorted in descending order (default is ascending)


Optional. Specifies the language code of the culture to localize the representation of the resource in. This requires the appropriate language packs to be installed on the FIM/MIM Service. e.g en-US, de-de, ja-jp, es-es, it-it.


Get all sets

# This command will retrieve all sets, but as neither the AttributesToGet or ExpectedObjectType parameters have been specified, only the ObjectID and ObjectType attributes will be returned
Search-Resources -Xpath "/Set"

Get resources with specific attributes

# Get all users with AccountName starting with 't', returning only the AccountName and Domain attributes
Search-Resources -Xpath "/Set[starts-with(AccountName, 't')]" -AttributesToGet @("AccountName","Domain")

Get first 20 resources matching a criteria

# Get the first 20 users with AccountName starting with 't', returning only the AccountName and Domain attributes. The results will be sorted by DisplayName and AccountName
Search-Resources -Xpath "/Set[starts-with(AccountName, 't')]" -AttributesToGet @("AccountName","Domain") -MaxResults 20 -SortAttributes @("DisplayName","AccountName")

Get resources with a known object type

# This command gets all workflow definition objects. As the object type returned from the query is known, the command will return all attributes in the schema for the WorkflowDefinition type as part of the result set
Search-Resources -Xpath "/WorkflowDefinition" -ExpectedObjectType WorkflowDefinition

Get resources using the XPath query builder

# Creates an expression that searches for users with the account name 'ryan'
$query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan"
$expression = New-XPathExpression -ObjectType "Person" -QueryObject $query
Search-Resources $expression

Get the localized representation of a set of resources

# Gets all ObjectTypeDescription objects localized in Italian
Search-Resources -XPath "/ObjectTypeDescription" -ExpectedObjectType "ObjectTypeDescription" -Locale it-IT
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.