> For the complete documentation index, see [llms.txt](https://docs.lithnet.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/search-resourcespaged.md).

# Search-ResourcesPaged

### Description

The `Search-ResourcesPaged` cmdlet allows you to perform a query for multiple objects from the FIM Service, with advanced controls of how you navigate through the result set. For standard searching, see the [Search-Resources](/resource-management-powershell/usage/cmdlet-reference/search-resources.md) cmdlet. 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] [-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>]
```

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

**Locale**

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.

### Examples

**Iterate through a result set one page at a time**

The following example shows how to use the pager to iterate through a result set one page a time

```powershell
# Get a pager to enumerate all sets
$pager = Search-ResourcesPaged -Xpath "/Set";
$pager.PageSize = 10;

# Loop through the result set until there are no more results
while ($pager.HasMoreItems)
{
    # Get 10 results
    $resultSet = $pager.GetNextPage();
    
    # Iterate through each result and print the ObjectID
    foreach($result in $resultSet)
    {
        $result.ObjectID
    }

# Repeat until all results have been processed
}
```

**Iterate through the result set, starting from a specific point**

The following example shows how to move position in the result set, and starts the operation from the 50th set.

```powershell
$pager = Search-ResourcesPaged -Xpath "/Set";
$pager.PageSize = 10;
$pager.CurrentIndex = 50;
# Loop through the result set until there are no more results
while ($pager.HasMoreItems)
{
    # Get 10 results
    $resultSet = $pager.GetNextPage();
    
    # Iterate through each result and print the ObjectID
    foreach($result in $resultSet)
    {
        $result.ObjectID
    }

# Repeat until all results have been processed
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/search-resourcespaged.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
