RunspaceFactory.CreateRunspacePool Method (Int32, Int32, PSHost, RunspaceConnectionInfo)

Creates a pool of runspaces that use the specified path, on which the runspaces are run, the specified host application, and the minimum and maximum number of runspaces allowed to be run at one time.


Namespace: System.Management.Automation.Runspaces
Assembly: System.Management.Automation (in system.management.automation.dll)

public static RunspacePool CreateRunspacePool (
	int minPoolSize,
	int maxPoolSize,
	PSHost host,
	RunspaceConnectionInfo path
)
public static RunspacePool CreateRunspacePool (
	int minPoolSize, 
	int maxPoolSize, 
	PSHost host, 
	RunspaceConnectionInfo path
)
public static function CreateRunspacePool (
	minPoolSize : int, 
	maxPoolSize : int, 
	host : PSHost, 
	path : RunspaceConnectionInfo
) : RunspacePool

Parameters

minPoolSize

The minimum number of opened runspaces that Windows PowerShell maintains open even if the runspaces are no longer needed (default is one). Typically, destroys opened runspaces when they are no longer needed.

maxPoolSize

The maximum number of runspaces that are allowed to be open. Set to a value greater than the minPoolSize parameter.

host

A PSHost object that represents the host. A host is needed to interact or communicate directly with the user through prompting.

path

An object that derives from the RunspaceConnectionInfo abstract class. This object defines the information used to connect to a specific computer.

Return Value

A RunspacePool object that represents the pool with the maximum number of runspaces, and the minimum number of runspaces maintained open. When a runspace from the pool is opened, the runspace uses the specified host and connection information.

Exception typeCondition
ArgumentNullException

The path or host parameter is set to null.

ArgumentException

The minPoolSize or maxPoolSize parameter is set to a value less than 1.

A runspace pool is a set of runspaces that have the same features, such as the same host, initial session state, and connection information. A runspace from the pool is the operating environment used when invoking the commands of a pipeline. Once the runspace pool is created, a runspace from the pool must be opened using one of the following methods before it can be used:

  • To open a runspace from the pool synchronously, call the Open method.

  • To open a runspace from the pool asynchronously, call the BeginOpen method.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP
Show: