dbatools – Run the sql query against all instances in the group on the CMS

I love dbatools. Lately, I have been using it regularly on my job. One thing that I do from time to time is check on various parameters like uptime, version, edition etc on various SQL servers. I would love to be able to check the uptime or latest cumulative update version on a group of servers registered under Central management server. Below is a command I found through dbatools module:

Get-DbaRegServer -SqlInstance [SERVERNAME] -Group Production | Invoke-DbaQuery -Query 'SELECT @@version'

The above one-line statement runs the query SELECT @@version across all the servers registered under group name Production on Central management server.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: