PowerShell - Get Network Card Metrics
- Jon Boyette
- Feb 10, 2022
- 1 min read
Save as getlocalmetrics.ps1, once ran this will show the Metrics setting of all IPV4 and IPV6 and if connected or disconnected, used to prioritize Wifi and Ethernet connections
[CmdletBinding()]
param (
[ValidateSet ("IPv4","IPv6")]
[String]$AddressFamily
)
Get-NetIPInterface @PSBoundParameters | Sort-Object InterfaceMetric | ForEach-Object {
if($_.InterfaceAlias -eq 1) { return; }
$adapter= Get-NetAdapter
$address=$_ | Get-NetIPAddress
[PSCustomObject]@{
InterfaceAlias=$_.InterfaceAlias;
InterfaceIndex=$_.InterfaceIndex;
Address="$($address.IPAddress)/$($address.PrefixLength)"
Metric=$_.InterfaceMetric;
Speed=$adapter.LinkSpeed
}
} | ft
Comments