Discover SQL Servers with Powershell
With Powershell and SMO you can easily discover SQL Server instances running on your network in just a few lines of code.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;
$smoObj = [Microsoft.SqlServer.Management.Smo.SmoApplication];
# This gets the sql servers available
$sql = $smoObj::EnumAvailableSqlServers($false)
foreach($sqlserver in $sql)
{
Write-Host -ForegroundColor Green "Discovered sql server: " $sqlserver.Name;
}
If this doesn’t seem to find all your sql servers check firewalls and the SQL Server Browser Service is running.