If a computer has multiple gateways, how can I determine which is the default gateway using the PowerShell?
If you're on PowerShell v3, you can use Get-NetIPConfiguration
e.g.:
Get-NetIPConfiguration | Foreach IPv4DefaultGateway
I think this will be more cross platform:
Get-NetRoute |
where {$_.DestinationPrefix -eq '0.0.0.0/0'} |
select { $_.NextHop }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With