Skip to content

Running SQL Scripts Against Multiple Servers Using PowerShell

In this post I’m going to share a function I use run scripts against multiple instances of SQL servers and run the data into a GridView. I use this mainly for a replacement of the CMS feature of running against a folder and to put the output to a GridView that I can sort and filter any way I want which you can’t do in CMS.

The first function Get-CmsHosts was written by my colleague Mark Wilkinson (m82labs.com) to pull a pattern of hosts from your CMS server or your can pass an -InstanceList as a file or comma separate list.

Then I use PSSessions to run any query I specify and output to a GridView.

 

One thought on “Running SQL Scripts Against Multiple Servers Using PowerShell

  1. Pingback: Query All Servers In A CMS Folder – Curated SQL

Leave a Comment