PowerShell NetAdapter module (3/3)
Part 3 of the NetAdapter module: the cmdlets that change an adapter (Set-, New-, Remove-, Rename-, Reset-, Restart-NetAdapter*). They rename adapters, set VLAN/MAC, edit driver advanced properties, bindings, offloads, RSS/VMQ/SR-IOV and power. Almost all of them need admin and can restart the adapter.
215.1 Why is it used?
- Rename adapters to meaningful names (ManagementAdapter) and set VLAN ID or MAC from a script.
- Change driver settings (Jumbo Packet, Flow Control, Interrupt Moderation) the same way on many servers.
- Tune offloads and scaling (LSO, RSC, USO, RSS, VMQ, SR-IOV) and power (Wake on LAN).
- Restart an adapter so a property takes effect.
215.2 Where it runs and the risk
- Built into Windows 10/11 and Server, PowerShell 5.1 and 7; every cmdlet in this part needs admin.
- Most of them restart the adapter after the change, so the connection drops for a few seconds.
- The office PC in the video is on VPN, so none were run (not even -WhatIf); only Get-Command / Get-Help ran, the rest is from Microsoft Learn and a Linux lab.
- Step 1
1.Laptop is connected via switch and router to the office VPN
- Step 2
2.Admin runs Set-NetAdapterAdvancedProperty
- Step 3
3.Driver restarts the adapter to apply the new value
- Step 4
4.Link goes down: packets do not even reach the switch
- Step 5
5.Remote session and VPN both disconnect
Do this work in a maintenance window or with console access
Get-Command -Module NetAdapter ` -Verb Set,New,Remove,Rename,Reset,Restart | Measure-ObjectGet-Help Set-NetAdapter$ Get-Command -Module NetAdapter -Verb Set,New,Remove,Rename,Reset,Restart | Measure-ObjectCount : 23$ Get-Help Set-NetAdapterNAME Set-NetAdapterSYNTAX Set-NetAdapter [-Name] <string[]> [-IncludeHidden] [-VlanID <uint16>] [-MacAddress <string>] [-NoRestart] [-CimSession <CimSession[]>] [-ThrottleLimit <int>] [-AsJob] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]...REMARKS Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help. -- To download and install Help files for the module that includes this cmdlet, use Update-Help.215.3 Set-NetAdapter, Rename-NetAdapter, Restart-NetAdapter
# Example (docs), admin only, NOT run here:Set-NetAdapter -Name "Ethernet 1" -VlanID 10Set-NetAdapter -Name "Ethernet 1" ` -MacAddress "00-10-18-57-1B-0D"Rename-NetAdapter -Name "Ethernet" ` -NewName "ManagementAdapter"Restart-NetAdapter -Name "Ethernet 2"- Set-NetAdapter changes basic properties: -VlanID (not every adapter supports it), -MacAddress, -NoRestart. Docs warn these changes could disrupt networking.
- Rename-NetAdapter changes only the name (interface alias); the InterfaceDescription stays the same. Wildcards work (-Name "E*t").
- Restart-NetAdapter disables then enables the adapter, which some properties need before they apply.
215.4 Advanced properties: Set, Reset, New, Remove
Set-NetAdapterAdvancedProperty -Name "MyAdapter" ` -DisplayName "Flow Control" ` -DisplayValue "Rx and Tx Enabled"Set-NetAdapterAdvancedProperty -Name "MyAdapter" ` -RegistryKeyword "*Flo*rol" -RegistryValue 0Reset-NetAdapterAdvancedProperty -Name "MyAdapter" ` -DisplayName "Interrupt Moderation"Reset-NetAdapterAdvancedProperty -Name "MyAdapter" -DisplayName "*"New-NetAdapterAdvancedProperty -Name "MyAdapter" ` -RegistryKeyword "MyKeyword" ` -RegistryValue "1" -RegistryDataType REG_SZRemove-NetAdapterAdvancedProperty -Name "MyAdapter" ` -RegistryKeyword "myKeyword" -AllProperties| Cmdlet | Does |
|---|---|
| Set-NetAdapterAdvancedProperty | Sets a value by -DisplayName/-DisplayValue or -RegistryKeyword/-RegistryValue; written straight to the registry |
| Reset-NetAdapterAdvancedProperty | Back to factory default; -DisplayName "*" resets all |
| New-NetAdapterAdvancedProperty | Creates a new registry keyword with -RegistryDataType (REG_SZ, REG_DWORD...) |
| Remove-NetAdapterAdvancedProperty | Deletes a keyword; a keyword without display name needs -AllProperties |
215.5 Set-NetAdapterBinding
Set-NetAdapterBinding -Name "MyAdapter" ` -ComponentID ms_tcpip -Enabled $TrueSet-NetAdapterBinding -Name "MyAdapter" ` -DisplayName "Internet Protocol Version 4 (TCP/IPv4)" ` -Enabled $False- -ComponentID ms_tcpip (IPv4), ms_tcpip6 (IPv6), ms_server (file sharing); -DisplayName is the Networking tab name; -AllBindings includes hidden filters.
- The riskiest example: as soon as the IPv4 binding is off, IPv4 traffic on that adapter stops.
215.6 Offload, scaling and power Set cmdlets
- Step 1
1.Server TCP stack hands one 64 KB segment to the NIC
- Step 2
2.LSO: NIC cuts it into 1500-byte frames (USO does the same for UDP)
- Step 3
3.Frames travel through the switch to the client
- Step 4
4.RSC on the receiver joins small frames back into one segment
- Step 5
5.RSS spreads incoming traffic over several CPU cores
| Cmdlet | Key options |
|---|---|
| Set-NetAdapterChecksumOffload | -IpIPv4Enabled, -TcpIPv4Enabled, -UdpIPv6Enabled ...: Disabled | TxEnabled | RxEnabled | RxTxEnabled |
| Set-NetAdapterLso / -Rsc / -Uso | -IPv4Enabled $True/$False, -IPv6Enabled; Lso also -V1IPv4Enabled |
| Set-NetAdapterIPsecOffload | -Enabled $True (docs prefer the Enable- cmdlet) |
| Set-NetAdapterEncapsulatedPacketTaskOffload | -VxlanEncapsulatedPacketTaskOffloadEnabled, -NvgreEncapsulatedPacketTaskOffloadEnabled, -VxlanUDPPortNumber |
| Set-NetAdapterDataPathConfiguration | -Profile Dispatch|Balanced|Legacy|Passive (client default Balanced) |
| Set-NetAdapterPowerManagement | -WakeOnMagicPacket, -WakeOnPattern, -ArpOffload, -NSOffload, -SelectiveSuspend, -DeviceSleepOnDisconnect |
| Set-NetAdapterRss | -Profile Closest|ClosestStatic|NUMA|NUMAStatic|Conservative, -NumberOfReceiveQueues, -MaxProcessors, -NumaNode |
| Set-NetAdapterVmq | -Enabled, -BaseProcessor*, -MaxProcessors |
| Set-NetAdapterSriov / -Rdma / -Qos | -NumVFs, -Enabled, queue pairs |
Set-NetAdapterChecksumOffload -Name "*" -IpIPv4Enabled RxTxEnabledSet-NetAdapterLso -Name "MyAdapter" -IPv4Enabled $True -IPv6Enabled $FalseSet-NetAdapterRsc -Name "MyAdapter" -IPv4Enabled $False -IPv6Enabled $FalseSet-NetAdapterEncapsulatedPacketTaskOffload -Name "MyAdapter" ` -VxlanEncapsulatedPacketTaskOffloadEnabled $TrueSet-NetAdapterPowerManagement -Name "Ethernet" ` -DeviceSleepOnDisconnect EnabledSet-NetAdapterRss -Name "Ethernet" -Profile NUMAStaticSet-NetAdapterSriov -Name "Ethernet 2" -NumVFs 31 ` -NumQueuePairsForDefaultVPort 2 ` -NumQueuePairsForNonDefaultVPort 2Set-NetAdapterQos -Name "DCBAdapter2" -Enabled $False- NUMAStatic RSS profile: for a NUMA server without dynamic load balancing.
- Docs: 31 SR-IOV virtual functions also gives 32 VMQs.
- ArpOffload / NSOffload let the NIC answer ARP and IPv6 NS while the PC sleeps.
215.7 Linux equivalents (Docker lab)
| Windows | Linux |
|---|---|
| Rename-NetAdapter | ip link set n215-a name lan0 |
| Set-NetAdapter -MacAddress | ip link set lan0 address 02:00:00:00:02:15 |
| Set-NetAdapterAdvancedProperty (Jumbo Packet) | ip link set lan0 mtu 9000 |
| Restart-NetAdapter | ip link set lan0 down; ip link set lan0 up |
| Set-NetAdapterLso / -Rsc | ethtool -K lan0 tso off gro on |
| Set-NetAdapterRss (queues) | ethtool -l lan0 |
| Set-NetAdapterPowerManagement -WakeOnMagicPacket | ethtool -s eth0 wol g |
ip link add n215-a type veth peer name n215-bip link set n215-a upip link set n215-a name lan0ip link set lan0 address 02:00:00:00:02:15ip -br link show lan0ip link set lan0 mtu 9000ip link set lan0 downip -br addr show lan0ip link set lan0 upip -br addr show lan0$ ip -br link show lan0lan0@n215-b LOWERLAYERDOWN 02:00:00:00:02:15 <NO-CARRIER,BROADCAST,MULTICAST,UP,M-DOWN>$ ip link set lan0 mtu 9000$ ip link show lan0 | head -18: lan0@n215-b: <NO-CARRIER,BROADCAST,MULTICAST,UP,M-DOWN> mtu 9000 qdisc noqueue state LOWERLAYERDOWN ...$ ip -br addr show lan0lan0@n215-b UP 192.168.235.215/24 fe80::ff:fe00:215/64$ ip link set lan0 down$ ip -br addr show lan0lan0@n215-b DOWN 192.168.235.215/24$ ip link set lan0 up$ ip -br addr show lan0lan0@n215-b UP 192.168.235.215/24 fe80::ff:fe00:215/64- The dummy driver was a not-loaded module (CONFIG_DUMMY=m), so a built-in veth pair (CONFIG_VETH=y) was used.
- During down the IPv6 link-local address disappeared and came back on up: on a real adapter your connection drops in exactly this gap.
ethtool -K lan0 tso off gro onethtool -K lan0 lro onethtool -s eth0 wol gecho "exit code: $?"$ ethtool -K lan0 tso off gro on$ ethtool -k lan0 (trimmed)tcp-segmentation-offload: offgeneric-receive-offload: on$ ethtool -K lan0 lro onActual changes:rx-lro: off [requested on]Could not change any device features$ ethtool -s eth0 wol gnetlink error: Not supported$ echo "exit code: $?"exit code: 75215.8 Common mistakes
- Changing Jumbo Packet over RDP: the adapter restarts and the RDP session drops; use a maintenance window or console access.
- Believing -NoRestart means no drop: it only postpones it; many advanced properties apply only after a restart or reboot.
- Disabling the IPv4 binding on the adapter you manage the server through.
- Expecting Rename-NetAdapter to change InterfaceDescription: only the alias changes.
215.9 Interview tips
- Name/VLAN/MAC: Rename-NetAdapter and Set-NetAdapter; driver settings: Set-NetAdapterAdvancedProperty (registry).
- Offload and scaling: Set-NetAdapterLso / Rsc / Rss; protocols: Set-NetAdapterBinding.
- All need admin and can restart the adapter: on a remote server work in a maintenance window.
- Linux: ip link (name, address, mtu, down/up) and ethtool (-K offloads, -l channels, -s wol).