PowerShell NetAdapter module (1/3)
The NetAdapter module manages every physical and virtual network card in Windows as an object: switch it off/on, change protocol bindings, offloads (checksum, LSO, USO, RSC), power and server features like RSS, VMQ and SR-IOV. Part 1 covers the Disable-/Enable- cmdlets.
213.1 Why is it used?
- Take an adapter down or bring it back Up from a script (Disable-/Enable-NetAdapter).
- Turn a protocol like IPv4 or IPv6 off on one adapter (bindings).
- Switch NIC offloads off while troubleshooting a driver or a confusing packet capture.
- Control Wake on LAN and sleep, and server features (QoS/DCB, RSS, VMQ, SR-IOV, RDMA).
213.2 Where it runs
- Built into Windows 10/11 and Windows Server; Windows PowerShell 5.1 and PowerShell 7.
- Disable-/Enable- cmdlets need an Administrator PowerShell.
- Linux has no single module: ip link and ethtool do the same job.
- In the video only read-only help commands were run on the office PC; the changes were done in a Linux Docker lab.
Get-Command -Module NetAdapter | Measure-ObjectGet-Help Disable-NetAdapterPS> Get-Command -Module NetAdapter | Measure-Object Count : 78PS> Get-Help Disable-NetAdapterNAME Disable-NetAdapterSYNTAX Disable-NetAdapter [-Name] <string[]> [-IncludeHidden] [-PassThru] [-CimSession <CimSession[]>] [-ThrottleLimit <int>] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>] Disable-NetAdapter -InterfaceDescription <string[]> [-IncludeHidden] [-PassThru] [-CimSession <CimSession[]>] Disable-NetAdapter -InputObject <CimInstance#MSFT_NetAdapter[]> [-PassThru] [-CimSession <CimSession[]>]213.3 Common parameters
| Parameter | What it does |
|---|---|
| -Name / -InterfaceDescription / -InputObject | Three ways to select the adapter |
| -WhatIf | Preview only, no change |
| -Confirm | Ask before running |
| -CimSession Server01 | Run on a remote computer |
| -AsJob / -ThrottleLimit 8 | Background job / max parallel operations |
| -IncludeHidden | Hidden adapters too |
| -PassThru | Return the changed object |
| -NoRestart | (offload/binding cmdlets) do not restart the adapter |
213.4 Disable-NetAdapter and Enable-NetAdapter
- Step 1
1.Packet leaves the PC through Ethernet 2, via the office switch, to the file server
- Step 2
2.Admin runs Disable-NetAdapter: adapter off, link cut
- Step 3
3.Next packet does not even leave the PC; status = Disabled
- Step 4
4.Enable-NetAdapter: adapter comes back on
- Step 5
5.Link and IP stack ready: status = Up, traffic flows again
# Example (docs), admin only, NOT run here:Disable-NetAdapter -Name "MyAdapter"Disable-NetAdapter -Name "MyAdapter" ` -Confirm:$FalseDisable-NetAdapter -Name "*"Enable-NetAdapter -Name "Ethernet 1"Disable-NetAdapter ` -Name "VMGuestTrafficAdapter" ` -CimSession HyperVServer4PS C:\> Disable-NetAdapter -Name "MyAdapter"ConfirmAre you sure you want to perform this action?Disable-NetAdapter 'MyAdapter' [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):Y- Disable-NetAdapter asks for confirmation by default (docs example output above); -Confirm:$False skips the prompt.
- -Name "*" disables every adapter: never run it on a remote machine, the connection will not come back.
- Enable-NetAdapter accepts the same selectors and wildcards (Enable-NetAdapter "E*2").
Linux equivalent (real lab): ip link set eth0 down / up.
ip -br link show eth0ping -c 2 -W 1 192.168.233.20ip link set eth0 downip -br link show eth0ping -c 2 -W 1 192.168.233.20ip link set eth0 upping -c 2 -W 1 192.168.233.20$ ip -br link show eth0eth0@if1641 UP 2a:7b:d0:3f:24:d0 <BROADCAST,MULTICAST,UP,LOWER_UP>$ ping -c 2 -W 1 192.168.233.2064 bytes from 192.168.233.20: icmp_seq=1 ttl=64 time=1.87 ms64 bytes from 192.168.233.20: icmp_seq=2 ttl=64 time=0.154 ms2 packets transmitted, 2 received, 0% packet loss, time 1002ms$ ip link set eth0 down$ ip -br link show eth0eth0@if1641 DOWN 2a:7b:d0:3f:24:d0 <BROADCAST,MULTICAST>$ ping -c 2 -W 1 192.168.233.20ping: connect: Network unreachable$ ip link set eth0 up$ ip -br link show eth0eth0@if1641 UP 2a:7b:d0:3f:24:d0 <BROADCAST,MULTICAST,UP,LOWER_UP>$ ping -c 2 -W 1 192.168.233.2064 bytes from 192.168.233.20: icmp_seq=1 ttl=64 time=0.169 ms64 bytes from 192.168.233.20: icmp_seq=2 ttl=64 time=0.136 ms2 packets transmitted, 2 received, 0% packet loss, time 1019ms213.5 Bindings
- A binding = which protocols/filters are attached to an adapter (IPv4, IPv6, file sharing...).
- Select a binding by -ComponentID (ms_tcpip = IPv4, ms_tcpip6 = IPv6) or -DisplayName (wildcards allowed); -AllBindings hits every protocol.
Disable-NetAdapterBinding -Name "MyAdapter" ` -ComponentID ms_tcpipEnable-NetAdapterBinding -Name "MyAdapter" ` -ComponentID ms_tcpip213.6 Offloads: checksum, LSO, USO, RSC, encapsulated, IPsec
- Step 1
1.Without offload the CPU cuts TCP data into segments and computes every checksum
- Step 2
2.With offload Windows hands the NIC one big 64 KB chunk
- Step 3
3.NIC cuts it into 1500-byte frames (LSO)
- Step 4
4.NIC fills in the checksums (checksum offload)
- Step 5
5.CPU stays free; frames go via the switch to the server
| Offload | What the NIC does | Switches |
|---|---|---|
| Checksum | Computes IP/TCP/UDP checksums | -IpIPv4 -TcpIPv4 -TcpIPv6 -UdpIPv4 -UdpIPv6 (none = all) |
| LSO (Large Send Offload) | Cuts a big TCP chunk into frames | -IPv4 -IPv6 (none = both) |
| USO (UDP Segmentation Offload) | Same as LSO for UDP sends | -IPv4 -IPv6 |
| RSC (Receive Segment Coalescing) | Combines many received packets into one big packet | -IPv4 -IPv6 |
| Encapsulated packet task offload | LSO/VMQ on the inner header of NVGRE/VXLAN tunnels | -EncapsulationType NVGRE|VXLAN |
| IPsec offload | Per-packet IPsec crypto on the NIC | -Name / -InterfaceDescription / -InputObject |
Disable-NetAdapterChecksumOffload -Name "*" -TcpIPv6Enable-NetAdapterChecksumOffload -Name "*" ` -TcpIPv4 -UdpIPv4 -IpIPv4Disable-NetAdapterLso -Name "MyAdapter" -IPv6Enable-NetAdapterLso -Name "*" -IPv4 -IPv6Disable-NetAdapterUso -Name "MyAdapter" -IPv6Disable-NetAdapterRsc -Name "MyAdapter" -IPv6Disable-NetAdapterIPsecOffload -Name "MyAdapter"Linux equivalent (real lab): ethtool -K for checksum (tx/rx) and LSO (tso/gso).
ethtool -k eth0ethtool -K eth0 tx offethtool -K eth0 rx offethtool -K eth0 tx on rx onethtool -K eth0 tso off gso offethtool -K eth0 tso on gso on$ ethtool -k eth0rx-checksumming: ontx-checksumming: on tx-checksum-ip-generic: ontcp-segmentation-offload: ongeneric-segmentation-offload: ontx-udp-segmentation: on$ ethtool -K eth0 tx offActual changes:tx-checksum-ip-generic: offtx-tcp-segmentation: off [not requested]tx-udp-segmentation: off [not requested]$ ethtool -K eth0 tso off gso off$ ethtool -k eth0tcp-segmentation-offload: off tx-tcp-segmentation: offgeneric-segmentation-offload: off- Turning tx checksum off made the kernel also switch off TCP/UDP segmentation: segmentation offload cannot work without checksum offload.
- On Linux LSO is called TSO; GSO is its software version.
213.7 Power management, QoS, RSS, VMQ, SR-IOV, RDMA
- Power: -WakeOnMagicPacket (Wake on LAN), -WakeOnPattern, -ArpOffload / -NSOffload (NIC answers ARP/IPv6 NS during sleep), -SelectiveSuspend, -DeviceSleepOnDisconnect; no switch = all features.
- QoS = DCB (Data Center Bridging) features that give storage/RDMA traffic priority and bandwidth.
- RSS spreads receive traffic over many CPU cores; VMQ gives each Hyper-V VM its own receive queue. Docs: disabling them can reduce performance.
- SR-IOV gives a VM a direct NIC hardware path bypassing the Hyper-V switch; RDMA copies memory to memory without the CPU (SMB Direct).
$NetAdapter1 = Get-NetAdapter -Name "Ethernet 3"Disable-NetAdapterPowerManagement ` -InputObject $NetAdapter1Get-NetAdapterQos -Name "*" | Enable-NetAdapterQosDisable-NetAdapterRss -Name "MyAdapter"Disable-NetAdapterVmq -Name "GuestTrafficAdapter"Get-NetAdapter -Name "Ethernet 2" | Disable-NetAdapterSriovDisable-NetAdapterRdma -Name "MyAdapter"ethtool eth0 | grep -i -E "wake|link detected"ethtool -s eth0 wol g$ ethtool eth0 | grep -i -E "wake|link detected" Link detected: yes$ ethtool -s eth0 wol gnetlink error: Not supported(exit 75)- ethtool -s eth0 wol g (g = magic packet) failed with Not supported because the lab eth0 is a virtual veth; on a physical NIC with BIOS support it works.
213.8 Common mistakes
- Disabling the adapter you are connected through (RDP): the session drops and you cannot reconnect to run Enable-NetAdapter.
- Thinking an offload/binding change is harmless: the cmdlet restarts the adapter and the link drops for a moment.
- Relying on -NoRestart: it avoids the restart but many settings only take effect after a restart; use a maintenance window.
- Running Disable-NetAdapter -Name "*" on a remote server.
213.9 Interview tips
- LSO: the TCP/IP stack hands big data to the NIC and the NIC builds network-sized frames; checksum offload: the NIC computes checksums. Both lower CPU usage.
- Disable offloads (Disable-NetAdapterLso / -ChecksumOffload) for driver troubleshooting or when a capture shows bad checksums.
- Never disable the management adapter; use -WhatIf and -CimSession carefully.
- Linux mapping: Disable/Enable-NetAdapter = ip link set down/up; offloads = ethtool -K; Wake on LAN = ethtool -s wol g.