# NetworkUtils.ps1 — network detection utilities # Requires $InternalRoot to be defined in the calling script's scope before dot-sourcing. function Test-DnsSuffixConnected { <# .SYNOPSIS Returns $true if any currently UP network adapter has a connection-specific DNS suffix that contains the specified suffix string. #> [CmdletBinding()] [OutputType([bool])] param( [Parameter(Mandatory)] [string]$Suffix ) try { $clients = Get-DnsClient -ErrorAction Stop foreach ($client in $clients) { if ($client.ConnectionSpecificSuffix -notlike "*$Suffix*") { continue } # Verify the adapter is actually connected/up $adapter = Get-NetAdapter -InterfaceIndex $client.InterfaceIndex -ErrorAction SilentlyContinue if ($adapter -and $adapter.Status -eq 'Up') { return $true } } return $false } catch { Write-Log -Level Warn -Message "DNS suffix check failed for '$Suffix': $_" -Feature 'NetworkUtils' return $false } }