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


Invoke-DbaWhoIsActive

Outputs the results of Adam Machanic’s sp_WhoIsActive to DataTable.

You may also want to consider piping the results to Out-Gridview. GridView is good for analysis while DataTable is ideal for uploading the output to SQL Server using Write-DbaDataTable.

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. Outputs results to Out-GridView

Invoke-DbaWhoIsActive -SqlServer sqlserver2014a | Out-GridView

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.

Invoke-DbaWhoIsActive -SqlServer sqlserver2014a -SqlCredential $credential -Database dbatools

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

Invoke-DbaWhoIsActive -SqlServer sql2012 -FilterType Database -Filter SharePoint_Config

To run sp_WhoIsActive @get_avg_time

Invoke-DbaWhoIsActive -SqlServer sqlserver2014a -GetAverageTime

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

Invoke-DbaWhoIsActive -SqlServer sqlserver2014a -GetOuterCommand -FindBlockLeaders -OutputAs DataTable

Get-Help

From PowerShell, execute Get-Help Invoke-DbaWhoIsActive -Detailed for more information on this function.

Source Code

Want to see the source code? View Invoke-DbaWhoIsActive.ps1 on GitHub
 

Related commands