dbatools is a free PowerShell module with over 300 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


The dbatools module will have the diagnostic queries pre-installed. Use this only to update to a more recent version or specific versions.

This function is mainly used by Invoke-DbaDiagnosticQuery, but can also be used independently to download the Glenn Berry DMV scripts.

Use this function to pre-download the scripts from a device with an Internet connection.

The function Invoke-DbaDiagnosticQuery will try to download these scripts automatically, but it obviously needs an internet connection to do that.





Downloads the most recent version of all Glenn Berry DMV scripts to the specified location. If Path is not specified, the “My Documents” location will be used.

Save-DbaDiagnosticQueryScript -Path c:\temp


This command was created by André Kamman. You can find André on Twitter and his blog.


From PowerShell, execute Get-Help Save-DbaDiagnosticQueryScript -Detailed for more information on this function.

Source Code

Want to see the source code? View Save-DbaDiagnosticQueryScript.ps1 on GitHub

Related commands