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


Install-SqlWhoIsActive

Automatically installs or updates sp_WhoIsActive by Adam Machanic by downloading, extracting and installing sp_whoisactive.

Please consider donating to Adam if you find his stored procedure helpful.

TODO: Allow -Path to be specified for networks without Internet access.

Screenshots

Install-SqlWhoIsActive

Install-SqlWhoIsActive-2

Examples

To install sp_WhoIsActive to sqlserver2014a’s master database using Windows Authentication to login.

Install-SqlWhoIsActive -SqlServer sqlserver2014a -Database master

If no database is specified, you will be presented with a dialog box asking which database on sqlserver2014a you want to install the procedure within. If you’d like to use SQL authentication instead of Windows authentication, use the SqlCredential parameter.

$cred = Get-Credential
Install-SqlWhoIsActive -SqlServer sqlserver2014a -SqlCredential $cred

This command doesn’t support passing both servers and default database, but you can accomplish the same thing by passing an array and specifying a database.

$servers = Get-SqlRegisteredServerName sqlserver
Install-SqlWhoIsActive -SqlServer $servers -Database master

Get-Help

From PowerShell, execute Get-Help Install-SqlSpWhoIsActive -Detailed for more information on this function.

Source Code

Want to see the source code? View Install-SqlSpWhoIsActive.ps1 on GitHub
 

Related commands