Get-Runspace

Mendapatkan runspace aktif dalam proses host PowerShell.

Sintaks

Get-Runspace
   [[-Name] <String[]>]
   [<CommonParameters>]
Get-Runspace
   [-Id] <Int32[]>
   [<CommonParameters>]
Get-Runspace
   [-InstanceId] <Guid[]>
   [<CommonParameters>]

Deskripsi

Get-Runspace Cmdlet mendapatkan runspace aktif dalam proses host PowerShell.

Contoh

Contoh 1: Mendapatkan runspace

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

Contoh 2: Dapatkan runspace menurut Id

Get-Runspace -Id 2

Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  2 Runspace2       localhost       Local         Opened        Available

Contoh 3: Dapatkan runspace menurut Nama

Get-Runspace -Name Runspace1

Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  1 Runspace1       localhost       Local         Opened        Busy

Contoh 4: Mendapatkan runspace menurut InstanceId

Dalam contoh ini, kami mengidentifikasi runspace yang tersedia menggunakan Name parameter dan menyimpan objek pengembalian ke variabel $activeRunspace. Ini memungkinkan Anda untuk menggunakan properti Runspace dalam eksekusi berikutnya dari Get-Runspace.

$activeRunspace = Get-Runspace -Name Runspace1
Get-Runspace -InstanceId $activeRunspace.InstanceId

Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  1 Runspace1       localhost       Local         Opened        Busy

Parameter

-Id

Menentukan Id runspace

Type:Int32[]
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InstanceId

Menentukan GUID ID instans dari pekerjaan yang sedang berjalan.

Type:Guid[]
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Name

Menentukan Nama runspace

Type:String[]
Position:0
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Output

Runspace

Cmdlet ini mengembalikan Runspace. Anda dapat menyalurkan hasil Get-Runspace perintah ke Debug-Runspace.