Invoke-DbaDiagnosticQuery runs the scripts provided by Glenn Berry’s DMV scripts on specified servers. It is most often used in conjunction with Export-DbaDiagnosticQuery.
By default, Invoke-DbaDiagnosticQuery runs all queries and outputs to the console. You can use the -UseSelectionHelper switch, however, to select only specific queries to run.
This is the main function of the SQL Server Diagnostic Queries related functions in dbatools. The diagnostic queries are developed and maintained by Glenn Berry and they can be found here along with a lot of documentation.
The most recent version of the diagnostic queries are included in the dbatools module. But it is possible to download a newer set or a specific version to an alternative location and parse and run those scripts. It will run all or a selection of those scripts on one or multiple servers and return the result as a PowerShell Object
Invoke-DbaDiagnosticQuery -SqlInstance sql2016
Run the selection made by the user on the Sql Server instance specified.
Invoke-DbaDiagnosticQuery -SqlInstance sql2016 -UseSelectionHelper | Export-DbaDiagnosticQuery -Path C:\temp\gboutput
Provides a GridView with all the queries to choose from and will run the selection made by the user on the SQL Server instance specified. Then it will export the results to Export-DbaDiagnosticQuery which exports the resulting queries to C:\temp\gboutput in CSV format.