Skip to main content

Windows Network Management from the command line

Get interface metrics

# IPv4 - Display interfaces sorted by metric and alias
Get-NetIPInterface -AddressFamily IPv4 | Sort InterfaceMetric,InterfaceAlias

# IPv6 - Display interfaces sorted by metric and alias
Get-NetIPInterface -AddressFamily IPv6 | Sort InterfaceMetric,InterfaceAlias

# All - Display interfaces sorted by metric and alias
Get-NetIPInterface | Sort InterfaceMetric,InterfaceAlias

Set interface metrics

The following commands will set Ethernet interfaces to be preferred over wireless interfaces by manipulating the InterfaceMetric of each device. If there are more than one Ethernet and/or Wireless interface on the machine, you may want to adjust these metrics further to provide a more detailed use order.

# Set Ethernet devices interface metric to 11
Get-NetAdapter -Physical | Where {$_.MediaType -eq "802.3"} | Set-NetIPInterface -InterfaceMetric 11

# Set Wireless devices interface metric to 12
Get-NetAdapter -Physical | Where {$_.MediaType -eq "Native 802.11"} | Set-NetIPInterface -InterfaceMetric 12

netsh and firewall

# turn off Windows firewall for all profiles
netsh advfirewall set allprofiles state off

netsh wireless

# show wireless LAN interfaces on the system
netsh wlan show interfaces

# show properties of the wireless LAN drivers on the system
netsh wlan show drivers

# show list of networks visible on the system
netsh wlan show networks

# show more detailed information on visible networks
netsh wlan show networks mode=bssid

# show a list of profiles configured on the systme
netsh wlan show profiles

# connect to an SSID using a Profile
netsh wlan connect ssid=[ssid] name=[profile]

# disconnect all wireless interfaces
netsh wlan disconnect

 

Setting IPv4 address using netsh

netsh interface ipv4 show config

# set IPv4 address on an interface
netsh interface ipv4 set address name="Ethernet" static 10.1.1.84 255.255.255.0 10.1.1.1

# set DNS servers on an interface
netsh interface ipv4 set dns name="Ethernet" static 8.8.8.8 1.1.1.1