Settings a VLAN ID is yet another common task for network administrators, but using the Windows GUI for this is time-consuming as usual. In this article, you’ll learn how to do it quickly using PowerShell commands.
Setting the VLAN ID
Considering we’ve a network interface called Ethernet USB
this is how we can get the active VLAN ID:
Get-NetAdapterAdvancedProperty "Ethernet USB" -DisplayName "VLAN ID"
Note that network interface name is the one that shows up under Control Panel > Network Connections.
To switch to VLAN ID 55 run the following command:
Set-NetAdapterAdvancedProperty "Ethernet USB" -DisplayName "VLAN ID" -DisplayValue 55
Resetting the Interface
# Remove VLAN ID
Reset-NetAdapterAdvancedProperty "Ethernet USB" -DisplayName "VLAN ID"
# Restart the interface (optional)
Disable-NetAdapter -Name "Ethernet 2" -Confirm:$false; Enable-NetAdapter -Name "Ethernet 2" -Confirm:$false
That’s it! After setting the VLAN you may want to set static IP addresses and for that you can check my last article.