| external help file | Microsoft.PowerShell.Commands.Utility.dll-Help.xml |
|---|---|
| Locale | en-US |
| Module Name | Microsoft.PowerShell.Utility |
| ms.date | 12/12/2022 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-runspace?view=powershell-7.6&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Get-Runspace |
Gets active runspaces within a PowerShell host process.
Get-Runspace [[-Name] <String[]>] [<CommonParameters>]
Get-Runspace [-Id] <Int32[]> [<CommonParameters>]
Get-Runspace [-InstanceId] <Guid[]> [<CommonParameters>]
The Get-Runspace cmdlet gets active runspaces in a PowerShell host process.
Get-RunspaceId Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
2 Runspace2 localhost Local Opened Available
3 Runspace3 localhost Local Opened Available
Get-Runspace -Id 2Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
2 Runspace2 localhost Local Opened Available
Get-Runspace -Name Runspace1Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
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.InstanceIdId Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Busy
Specifies the Id of a runspace
Type: System.Int32[]
Parameter Sets: IdParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the instance ID GUID of a running job.
Type: System.Guid[]
Parameter Sets: InstanceIdParameterSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the Name of a runspace
Type: System.String[]
Parameter Sets: NameParameterSet
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This cmdlet returns a Runspace. You can pipe the results of a Get-Runspace command to
Debug-Runspace.