We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71373f6 commit f29c76dCopy full SHA for f29c76d
opt/Get-Runspace.ps1
@@ -0,0 +1,23 @@
1
+if (-not $ExecutionContext.SessionState.InvokeCommand.GetCommand('Get-Runspace','Function,Cmdlet')) {
2
+ function Get-Runspace {
3
+ try {
4
+ $runspaces = [Dataplat.Dbatools.Runspace.RunspaceHost]::Runspaces.Values
5
+ foreach ($rs in $runspaces) {
6
+ $availability = switch ($rs.State.ToString()) {
7
+ 'Running' { 'Available' }
8
+ default { 'NotAvailable' }
9
+ }
10
+ [PSCustomObject]@{
11
+ Id = $rs.RunspaceGuid
12
+ Name = $rs.Name
13
+ Type = $rs.GetType().Name
14
+ State = $rs.State
15
+ Availability = $availability
16
+ InstanceId = $rs.RunspaceGuid
17
18
19
+ } catch {
20
+ Write-Warning "Unable to enumerate dbatools-managed runspaces: $_"
21
22
23
+}
0 commit comments