HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Find all version of SQL Server on a network?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
allversionsqlfindservernetwork

Problem

There seems to be a bit of SQL Server sprawl at a client and I'd like to document all of them.

What is the best way to find all installed versions of SQL Server on a network?

Solution

If you want to programmatically find this information, you can make a call to the SqlDataSourceEnumerator.GetDataSources Method:

# PowerShell example
[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()


Something to note about this call, and documented in the above reference:


Due to the nature of the mechanism used by SqlDataSourceEnumerator to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical.

Another thing you could consider is to reach out across all of your servers (again, very time consuming) and get all services that contain a known SQL Server string in their name.

Get-Service -Name "mssql*"


If you loop through all your servers and grab all services that start with "MSSQL" you'll have a rudimentary list to start with. You may have to manually filter that down though.

Code Snippets

# PowerShell example
[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()
Get-Service -Name "mssql*"

Context

StackExchange Database Administrators Q#44171, answer score: 8

Revisions (0)

No revisions yet.