dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


This command has been aliased to Invoke-DbaWhoIsActive in v0.8.950.

To get the same results use Invoke-DbaWhoIsActive then pipe the results to Out-GridView.

Show-SqlWhoIsActive

Outputs the results of Adam Machanic’s sp_WhoIsActive to a GridView (default) or DataTable. GridView is good for analysis while DataTable is ideal for uploading the output to SQL Server (Write-SqlWhoIsActive coming soon :))

If sp_WhoIsActive is not installed in the system, it will be downloaded and installed to a database you specify with either -Database or a database you select from Show-SqlDatabaseList.

This is v0.1 of Show-SqlWhoIsActive. Better GridView formatting options and auto-population (tab completion) soon.

newwhoisactive

What’s really amazing about GridViews is the ability to filter and sort with extreme ease.

newfilterwhoisactive

Examples

To execute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the master database. Logs into the SQL Server with Windows credentials.

Show-SqlWhoIsActive -SqlServer sqlserver2014a

To execute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the dbatools database, and logs into the SQL Server with SQL Authentication.

Show-SqlWhoIsActive -SqlServer sqlserver2014a -SqlCredential $credential -Database dbatools

To run sp_WhoIsActive @filter_Type = ‘Database’, @filter = ‘SharePoint_Config’

Show-SqlWhoIsActive -SqlServer sql2012 -FilterType Database -Filter SharePoint_Config

To run sp_WhoIsActive @get_avg_time

Show-SqlWhoIsActive -SqlServer sqlserver2014a -GetAverageTime

To run sp_WhoIsActive @get_outer_command = 1, @find_block_leaders = 1 and output to a DataTable

Show-SqlWhoIsActive -SqlServer sqlserver2014a -GetOuterCommand -FindBlockLeaders -OutputAs DataTable

Get-Help

From PowerShell, execute Get-Help Show-SqlWhoIsActive -Detailed for more information on this function.

Source Code

Want to see the source code? View Show-SqlWhoIsActive.ps1 on GitHub
 

Related commands