# DistributedApplicationBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.PowerShell](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell.md)
- Type: [DistributedApplicationBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/distributedapplicationbuilderextensions.md)
- Kind: `Methods`
- Members: `1`

Extensions for the `Hosting.IDistributedApplicationBuilder` to add PowerShell runspace pool resources.

## AddPowerShell(IDistributedApplicationBuilder, string, PSLanguageMode, int, int)

- Name: `AddPowerShell(IDistributedApplicationBuilder, string, PSLanguageMode, int, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<PowerShellRunspacePoolResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.PowerShell/DistributedApplicationBuilderExtensions.cs)

Adds a PowerShell runspace pool resource to the distributed application, enabling managed execution of PowerShell scripts with configurable language mode and runspace limits.

```csharp
public static class DistributedApplicationBuilderExtensions
{
    public static IResourceBuilder<PowerShellRunspacePoolResource> AddPowerShell(
        this IDistributedApplicationBuilder builder,
        string name,
        PSLanguageMode languageMode = 3,
        int minRunspaces = 1,
        int maxRunspaces = 5)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The distributed application builder to which the PowerShell runspace pool resource will be added.
- `name` (`string`)
  The name of the PowerShell runspace pool resource. Cannot be null or whitespace.
- `languageMode` (`PSLanguageMode`) `optional`
  The language mode to use for the PowerShell runspace pool. Defaults to PSLanguageMode.ConstrainedLanguage.
- `minRunspaces` (`int`) `optional`
  The minimum number of runspaces to maintain in the pool. Must be at least 1.
- `maxRunspaces` (`int`) `optional`
  The maximum number of runspaces allowed in the pool. Must be greater than or equal to minRunspaces.

## Returns

`IResourceBuilder<PowerShellRunspacePoolResource>` -- An IResourceBuilder instance for further configuration of the PowerShell runspace pool resource.

## Remarks

This overload is not ATS-compatible due to the use of PSLanguageMode. For ATS scenarios, use the string-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
