Using PowerShell And SSMS Registered Servers

One of the interesting things about the PowerShell provider for SQL Server is that it is integrated so well into the entire environment.

As a case-in-point, you can use the PowerShell provider for SQL Server 2008 to read the registered servers in SQL Server Management Studio (SSMS) and then run a command against them. Here's how I do that:

dir "Database Engine Server Group" | % { invoke-sqlcmd -query "select serverproperty('ServerName') as [Server], serverproperty('ProductVersion') as [Version], serverProperty('ProductLevel') as [Level]" `
-ServerInstance $ | ft}

Comments (0)

Skip to main content