dbatools is a free PowerShell module with over 300 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


This function searches for SQL Server Instances.

It supports a variety of scans for this purpose which can be separated in two categories:
– Discovery
– Scan

This is where it compiles a list of computers / addresses to check.
It supports several methods of generating such lists (including Active Directory lookup or IP Ranges), but also supports specifying a list of computers to check.
– For details on discovery, see the documentation on the ‘-DiscoveryType’ parameter
– For details on explicitly providing a list, see the documentation on the ‘-ComputerName’ parameter

Once a list of computers has been provided, this command will execute a variety of actions to determine any instances present for each of them.
This is described in more detail in the documentation on the ‘-ScanType’ parameter.
Additional parameters allow more granular control over individual scans (e.g. Credentials to use).

Note on logging and auditing:
The Discovery phase is unproblematic since it is non-intrusive, however during the scan phase, all targeted computers may be accessed repeatedly.
This may cause issues with security teams, due to many logon events and possibly failed authentication.
This action constitutes a network scan, which may be illegal depending on the nation you are in and whether you own the network you scan.
If you are unsure whether you may use this command in your environment, check the detailed description on the ‘-ScanType’ parameter and contact your IT security team for advice.



Performs a network search for SQL Instances by:
– Looking up the Service Principal Names of computers in active directory
– Using the UDP broadcast based auto-discovery of SSMS
After that it will extensively scan all hosts thus discovered for instances.

Find-DbaInstance -DiscoveryType Domain,DataSourceEnumeration

Performs a network search for SQL Instances, using all discovery protocols:
– Active directory search for Service Principal Names
– SQL Instance Enumeration (same as SSMS does)
– All IPAddresses in the current computer’s subnets of all connected network interfaces
Note: This scan will take a long time, due to including the IP Scan

Find-DbaInstance -DiscoveryType All

Scans all computers in the domain for SQL Instances, using a deep probe:
– Tries resolving the name in DNS
– Tries pinging the computer
– Tries listing all SQL Services using CIM/WMI
– Tries discovering all instances via the browser service
– Tries connecting to the default TCP Port (1433)
– Tries connecting to the TCP port of each discovered instance
– Tries to establish a SQL connection to the server using default windows credentials
– Tries looking up the Service Principal Names for each instance

Get-ADComputer -Filter “*” | Find-DbaInstance

Reads all servers from the servers.txt file (one server per line), then scans each of them for instances using the browser service and finally attempts to connect to each instance found using the specified credentials.

Get-Content .\servers.txt | Find-DbaInstance -SqlCredential $cred -ScanType Browser,SqlConnect


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.


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

Source Code

Want to see the source code? View Find-DbaInstance.ps1 on GitHub

Related commands