What I really love about PowerShell is how simple it is to filter, extend and manipulate tabular data using the pipeline, in a way that resonates a lot with the experience of T-SQL developers.
The main part of the script is the one that invokes all the diagnostic queries included in the list
$queries
. This is done by invoking the cmdletInvoke-DbaDiagnosticQuery
, that takes care of using a version of the diagnostic query that matches the version of the target server and selecting the data. As usual with dbatools, the-SqlInstance
parameter accepts a list of servers, so you can pass in the list of all the SQL Servers in your infrastructure.
Gianluca has a GitHub repo for the script and explains it in more detail as well.