internal/Get-DbaRunspace.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Get-DbaRunspace {
<#
 .SYNOPSIS
  Returns registered runspaces.
  
 .DESCRIPTION
  Returns a list of runspaces that have been registered with dbatools
  
 .PARAMETER Name
  Default: "*"
  Only registered runspaces of similar names are returned.
  
 .EXAMPLE
  PS C:\> Get-DbaRunspace
  
  Returns all registered runspaces
  
 .EXAMPLE
  PS C:\> Get-DbaRunspace -Name 'mymodule.maintenance'
  
  Returns the runspace registered under the name 'mymodule.maintenance'
#>

    [CmdletBinding()]
    Param (
        [string]
        $Name = "*"
    )
    
    [Sqlcollaborative.Dbatools.Runspace.RunspaceHost]::Runspaces.Values | Where-Object Name -Like $Name
}