dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Get-SqlRegisteredServerName

This command gets a list of SQL Server names stored in SQL Server Central Management Server as a simple array.

Examples

Get a list of all server names from the Central Management Server on sqlserver2014a, using SQL Authentication

Get-SqlRegisteredServerName -SqlServer sqlserver2014a -SqlCredential $credential

Gets a list of server names in the HR and Accounting groups from the Central Management Server on sqlserver2014a.

Get-SqlRegisteredServerName -SqlServer sqlserver2014a -Group HR, Accounting

Find databases on Development and Production servers that aren’t online. Some commands don’t accept pipeline input, but for those that do, this is very powerful.

Get-SqlRegisteredServerName -SqlServer MySqlCmsServer -group development,production | get-dbaDatabaseState | Where-Object {$_.Status -ne ‘ONLINE’} | format-table

Screenshots

regnames

Get-Help

From PowerShell, execute Get-Help Get-SqlRegisteredServerName -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-SqlRegisteredServerName.ps1 on GitHub
 

Related commands