Home > Mobile >  Enable VLAN and set VLAN ID with powershell script if VLAN is not yet enabled
Enable VLAN and set VLAN ID with powershell script if VLAN is not yet enabled

Time:09-17

I'm right now trying to write a powershell script in Windows 11, that should automatically configure an usb to ethernet adapter. For this I need to automatically configure the VLAN of the adapter.

Everything works fine in case the VLAN was already activated in the network dialog using

Set-NetAdapter -Name Adapter -VlanID 999

In case the network adapter is not yet configured the script fails with:

Set-NetAdapter : Requested operation not supported on adapter

The screenshot shows on how to disable VLAN on the adapter.

VLAN is disabled in network settings

Does anyone knows how to enable VLAN with powershell in the first place prior to setting the VLAN ID?

CodePudding user response:

Try running the following command:

Get-NetAdapterAdvancedProperty

If you test with this you should be able to tell what property needs to be set e.g.

 Set-NetAdapterAdvancedProperty -DisplayName "Jumbo*" -DisplayValue "4088 Bytes"
  • Related