# list-ips.ps1 — prints reachable IPv4 addresses of this machine (one per line). # Used by run.bat to show http://:8080 access URLs. $ErrorActionPreference = "SilentlyContinue" $ips = New-Object System.Collections.Generic.List[string] # Primary: pure .NET network interfaces (locale independent). try { [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() | Where-Object { $_.OperationalStatus -eq [System.Net.NetworkInformation.OperationalStatus]::Up -and $_.NetworkInterfaceType -ne [System.Net.NetworkInformation.NetworkInterfaceType]::Loopback } | ForEach-Object { $_.GetIPProperties().UnicastAddresses } | Where-Object { $_.Address.AddressFamily -eq [System.Net.Sockets.AddressFamily]::InterNetwork -and $_.Address.IPAddressToString -notlike "127.*" -and $_.Address.IPAddressToString -notlike "169.254.*" } | ForEach-Object { $ips.Add($_.Address.IPAddressToString) } } catch {} # Fallback: parse ipconfig (handles localized output via the "IPv4" token). if ($ips.Count -eq 0) { ipconfig | Select-String -Pattern "IPv4" | ForEach-Object { if ($_ -match "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})") { $ip = $matches[1] if ($ip -notlike "127.*" -and $ip -notlike "169.254.*") { $ips.Add($ip) } } } } # Deduplicate and print. $ips | Sort-Object -Unique | ForEach-Object { Write-Output $_ }