Find-DbaInstance - Fix TcpConnected false for default instances#10327
Find-DbaInstance - Fix TcpConnected false for default instances#10327potatoqualitee merged 3 commits intodevelopmentfrom
Conversation
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>
|
@claude the test still fails in my lab. The first instance is correct, but the two others are wrong. Maybe this helps? Maybe you can add some verbose messages that help? |
|
Claude finished @andreasjordan's task in 7m 57s —— View job Fix pushedRoot cause: Changes made (commit ea0aaeb):
To test with verbose output: Find-DbaInstance -ComputerName sql03 -ScanType Browser, SqlConnect -Verbose | Format-Table SqlInstance, SqlConnected, TcpConnected| |
…s; add verbose messages
The TcpClient in Test-TcpPort was created once (in begin{}) and shared
across all port tests. After the first successful Connect()+Close(), the
client was disposed, causing all subsequent port tests to throw
ObjectDisposedException (caught, returning IsOpen=False).
Fix: create a new TcpClient per port test (moved to process{}) with
Dispose() in a finally block.
Also filter out port 0 from Browser results - DbaBrowserReply.TCPPort
defaults to 0 for instances that don't report a TCP port, and testing
port 0 can leave the socket in an error state.
Added Verbose messages throughout the Browser scan path to aid
debugging: Browser results, port test results, per-instance BrowseReply
TCPPort lookup and outcome.
Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
|
awesome, thank you! |

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:
Fixes #10322
Generated with Claude Code