Get-Runspace
Gets active runspaces within a PowerShell host process.
Syntax
Get-Runspace
[[-Name] <String[]>]
[<CommonParameters>]
Get-Runspace
[-Id] <Int32[]>
[<CommonParameters>]
Get-Runspace
[-InstanceId] <Guid[]>
[<CommonParameters>]
Description
The Get-Runspace cmdlet gets active runspaces in a PowerShell host process.
Examples
Example 1: Get runspaces
Get-Runspace
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
2 Runspace2 localhost Local Opened Available
3 Runspace3 localhost Local Opened Available
Example 2: Get runspace by Id
Get-Runspace -Id 2
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
2 Runspace2 localhost Local Opened Available
Example 3: Get runspace by Name
Get-Runspace -Name Runspace1
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
Example 4: Get runspace by InstanceId
In this example, we identify an available runspace using the Name parameter and store the return
object to the variable $activeRunspace. This allows you to use the properties of the Runspace
in subsequent runs of Get-Runspace.
$activeRunspace = Get-Runspace -Name Runspace1
Get-Runspace -InstanceId $activeRunspace.InstanceId
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
Parameters
-Id
Specifies the Id of a runspace
| Type: | Int32[] |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-InstanceId
Specifies the instance ID GUID of a running job.
| Type: | Guid[] |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Name
Specifies the Name of a runspace
| Type: | String[] |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Outputs
You can pipe the results of a Get-Runspace command to Debug-Runspace.
Related Links
Feedback
Submit and view feedback for