This project has moved. For the latest updates, please go here.

Search-Resources

Description

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.

Syntax

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

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

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

Parameters

XPath

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

ExpectedObjectType

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.

AttributesToGet

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

Unconstrained

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.

MaxResults

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

PageSize

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

SortAttributes

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

Descending

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

Examples

# Get all sets
Search-Resources -Xpath "/Set"

# 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 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")

# Gets all WorkflowDefinition objects, returning all the attributes that are present on the WorkflowDefinition
Search-Resources -Xpath "/WorkflowDefinition" -ExpectedObjectType WorkflowDefinition

# 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

Last edited Feb 27, 2016 at 12:03 AM by ryannewington, version 5