$ip = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | Where-Object { $_.IPAddress -match '^(172\.|192\.168\.|10\.)' } | Select-Object -First 1 -ExpandProperty IPAddress if ($ip) { Write-Output $ip }