---
title: Finding Service Instances Below A Root Path
slug: finding-service-instances-below-a-root-path
docTags: 
createdAt: 2026-01-29T22:41:06.070Z
---

# Overview

In Activate, service instances can be queried relative to a specific service tree location. This allows you to retrieve all service instances, or only those that exist under a defined service root.

This approach is commonly used in scripts where service instances need to be filtered by structure rather than by individual service names.

# How Service Root Filtering Works

The Services collection exposed on a user supports path-based access.

By passing a service root path, Activate returns a ServiceInstanceCollection containing all matching service instances beneath that path.

Wildcard paths can be used to include all child services.

# Example Usage

The following example demonstrates retrieving:

- All service instances assigned to the current user
- Only service instances under a specific sub-tree

:::BlockQuote
ServiceInstanceCollection col1 = CurrentUser.Services\["//Services/\*"] as ServiceInstanceCollection;
ServiceInstanceCollection col2 = CurrentUser.Services\["//Services/Examples/\*"] as ServiceInstanceCollection;

Trace.WriteLine($"All service instances count: &#x7B;col1.Count}");
Trace.WriteLine($"Examples service (and child service instances) instances count: &#x7B;col2.Count}");
:::

# Common Use Cases

This pattern is useful when you need to:

- Process or report on all services assigned to a user
- Restrict logic to services under a specific folder or category
- Compare service usage across different service branches

# Notes and Considerations

- Ensure the path exists in the service tree
- Use wildcards to include child services
- Results are limited to services assigned to the target user
