@@ -323,6 +323,28 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
323
323
return $database
324
324
}
325
325
326
+ function Get-WindowTitle
327
+ {
328
+ $title = " sp_WhoIsActive "
329
+ foreach ($param in $passedparams )
330
+ {
331
+ $sqlparam = $paramdictionary [$param ]
332
+ $value = $localparams [$param ]
333
+
334
+ switch ($value )
335
+ {
336
+ $true { $value = 1 }
337
+ $false { $value = 0 }
338
+ }
339
+
340
+ $title = " $title $sqlparam = $value , "
341
+ }
342
+
343
+
344
+ $title = $title.TrimEnd (" , " )
345
+ return $title
346
+ }
347
+
326
348
Function Invoke-SpWhoisActive
327
349
{
328
350
$sqlconnection = New-Object System.Data.SqlClient.SqlConnection
@@ -338,7 +360,7 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
338
360
$sqlcommand.CommandType = " StoredProcedure"
339
361
$sqlcommand.CommandText = " dbo.sp_WhoIsActive"
340
362
$sqlcommand.Connection = $sqlconnection
341
-
363
+
342
364
foreach ($param in $passedparams )
343
365
{
344
366
$sqlparam = $paramdictionary [$param ]
@@ -460,13 +482,15 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
460
482
461
483
if ($OutputAs -eq " DataTable" )
462
484
{
463
- return $datatable
485
+ $datatable.Tables
464
486
}
465
487
else
466
488
{
489
+ $windowtitle = Get-WindowTitle
490
+
467
491
foreach ($table in $datatable.Tables )
468
492
{
469
- $table | Out-GridView - Title " sp_WhoIsActive "
493
+ $table | Out-GridView - Title $windowtitle
470
494
}
471
495
}
472
496
}
0 commit comments