Skip to content

Commit ab9e409

Browse files
author
Chrissy LeMaire
authored
Merge pull request #70 from ctrlbold/feature-addtitlewhoisactive
added title to window
2 parents f5f6afa + 44c3185 commit ab9e409

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

functions/Show-SqlWhoIsActive.ps1

+27-3
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,28 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
323323
return $database
324324
}
325325

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+
326348
Function Invoke-SpWhoisActive
327349
{
328350
$sqlconnection = New-Object System.Data.SqlClient.SqlConnection
@@ -338,7 +360,7 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
338360
$sqlcommand.CommandType = "StoredProcedure"
339361
$sqlcommand.CommandText = "dbo.sp_WhoIsActive"
340362
$sqlcommand.Connection = $sqlconnection
341-
363+
342364
foreach ($param in $passedparams)
343365
{
344366
$sqlparam = $paramdictionary[$param]
@@ -460,13 +482,15 @@ Similar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders =
460482

461483
if ($OutputAs -eq "DataTable")
462484
{
463-
return $datatable
485+
$datatable.Tables
464486
}
465487
else
466488
{
489+
$windowtitle = Get-WindowTitle
490+
467491
foreach ($table in $datatable.Tables)
468492
{
469-
$table | Out-GridView -Title "sp_WhoIsActive"
493+
$table | Out-GridView -Title $windowtitle
470494
}
471495
}
472496
}

0 commit comments

Comments
 (0)