Press "Enter" to skip to content

Looping through SQL Server Instances in Powershell

Ajay Dwivedi has a script for us:

As a database administrator, often I have to fetch some metadata from all the SQLServers that we have. Other times, I have to execute some DDL or DML on all the servers.

In this blog and shared video, I show how to write a multiple server PowerShell script where server list source could range from raw text files to some inventory-based query result.

This is a serial operation, so you’re hitting one instance at a time. I’ve noticed that Powershell has about a half-dozen ways of performing parallel actions but they all seem to come with at least one fatal flaw.


  1. happydba

    I would be interested in the fatal flaws you mention!

    I have ps scripts that loop through servers serially, and always wanted to convert them to parallel some day. If serial is better/more stable or whatever it is, I would really be interested to know the details 🙂

Comments are closed.