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


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

From PowerShell, execute   Get-Help Show-SqlWhoIsActive -Detailed   for more information on this function. Want to see the source code? See it on GitHub