Skip to content

Commit 295c2b0

Browse files
Find-DbaInstance - Fix TcpConnected false for default instances
When Browser scan type is used, default SQL Server instances do not report a TCPPort via Browser UDP (clients are expected to use 1433). On SQL Server 2022+ where the Browser service is deprecated, no ports are returned at all. Both cases caused TcpConnected to remain false even when the instance was reachable over TCP. Fix: 1. After Browser scan, fall back to testing default TCP port(s) if Browser returned no port info (covers deprecated/absent Browser). 2. When BrowseReply exists but has no TCPPort (default instance), set TcpConnected/Port from any open port found in PortsScanned. Fixes #10322 Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 8987045 commit 295c2b0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

public/Find-DbaInstance.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ function Find-DbaInstance {
355355
# here to avoid an empty catch
356356
$null = 1
357357
}
358+
# Fall back to default port testing if Browser returned no port info
359+
# (e.g. SQL Server 2022+ where Browser is deprecated, or default instances
360+
# which don't report a TCP port via Browser UDP)
361+
if (-not $ports) {
362+
$ports = $TCPPort | Test-TcpPort -ComputerName $computer
363+
}
358364
} else {
359365
$ports = $TCPPort | Test-TcpPort -ComputerName $computer
360366
}
@@ -453,6 +459,13 @@ function Find-DbaInstance {
453459
$object.PortsScanned | Where-Object Port -EQ $object.Port | ForEach-Object {
454460
$object.TcpConnected = $_.IsOpen
455461
}
462+
} else {
463+
# Default instance - Browser doesn't report a specific TCP port,
464+
# check if any of the fallback ports we tested is open
465+
$object.PortsScanned | Where-Object IsOpen | Select-Object -First 1 | ForEach-Object {
466+
$object.Port = $_.Port
467+
$object.TcpConnected = $true
468+
}
456469
}
457470
}
458471
if ($object.Services) {

0 commit comments

Comments
 (0)