Skip to content
DocsTry Aspire
DocsTry

DistributedApplicationBuilderExtensions Methods

ClassMethods1 member
Extensions for the Hosting.IDistributedApplicationBuilder to add PowerShell runspace pool resources.
AddPowerShell(IDistributedApplicationBuilder, string, PSLanguageMode, int, int)Section titled AddPowerShell(IDistributedApplicationBuilder, string, PSLanguageMode, int, int)extensionIResourceBuilder<PowerShellRunspacePoolResource>
Adds a PowerShell runspace pool resource to the distributed application, enabling managed execution of PowerShell scripts with configurable language mode and runspace limits.
public static class DistributedApplicationBuilderExtensions
{
public static IResourceBuilder<PowerShellRunspacePoolResource> AddPowerShell(
this IDistributedApplicationBuilder builder,
string name,
PSLanguageMode languageMode = 3,
int minRunspaces = 1,
int maxRunspaces = 5)
{
// ...
}
}
builderIDistributedApplicationBuilderThe distributed application builder to which the PowerShell runspace pool resource will be added.
namestringThe name of the PowerShell runspace pool resource. Cannot be null or whitespace.
languageModePSLanguageModeoptionalThe language mode to use for the PowerShell runspace pool. Defaults to PSLanguageMode.ConstrainedLanguage.
minRunspacesintoptionalThe minimum number of runspaces to maintain in the pool. Must be at least 1.
maxRunspacesintoptionalThe maximum number of runspaces allowed in the pool. Must be greater than or equal to minRunspaces.
IResourceBuilder<PowerShellRunspacePoolResource>An IResourceBuilder instance for further configuration of the PowerShell runspace pool resource.
This overload is not ATS-compatible due to the use of PSLanguageMode. For ATS scenarios, use the string-based overload instead.