PowerShell NetSwitchTeam module
The NetSwitchTeam module joins several network adapters into one switch team so a server gets load balancing and failover. It has seven cmdlets that cover the whole lifecycle of a team, from New to Remove.
263.1 Why is it used?
- Failover: if one NIC cable is pulled or one switch dies, traffic moves to the other member and the connection stays up.
- Load balancing: different flows use different links, so both links carry traffic.
- Members can sit on different physical switches (Switch A, Switch B) for switch-level redundancy.
263.2 How it works
- Step 1
1.Server: Ethernet 1 -> Switch A, Ethernet 2 -> Switch B, both in SwitchTeam01
- Step 2
2.Normal: flow 1 uses Ethernet 1, flow 2 uses Ethernet 2
- Step 3
3.Ethernet 1 cable pulled / Switch A goes down
- Step 4
4.Team sees the link go down
- Step 5
5.All traffic shifts to Ethernet 2; client keeps getting replies
This is failover
- Built into Windows 10/11 and Windows Server; on the video's office PC the module has 7 cmdlets.
- A switch team is controlled by a forwarding extension of the Hyper-V extensible switch, so it is a server-side tool.
PowerShell
Get-Command -Module NetSwitchTeam -ErrorAction SilentlyContinue | Measure-ObjectOutput
PS C:\> Get-Command -Module NetSwitchTeam -ErrorAction SilentlyContinue | Measure-Object Count : 7263.3 Comparison: NetSwitchTeam vs LBFO vs SET
| Point | NetSwitchTeam | NetLbfo (LBFO) | SET (Hyper-V) |
|---|---|---|---|
| Mode | Switch-independent only | LACP / Static / Switch-independent | Switch-independent |
| Physical switch config | None needed | Needed for LACP/Static | None needed |
| Extras | Simple team | VLAN tNICs, load balancing algorithm | Recommended on Hyper-V hosts |
| Created with | New-NetSwitchTeam | New-NetLbfoTeam | New-VMSwitch -EnableEmbeddedTeaming |
263.4 Common parameters
- -AsJob runs the command as a background job.
- -CimSession Server01 runs the cmdlet on a remote server; -ThrottleLimit caps concurrent operations.
- -Confirm and -WhatIf exist only on Remove-NetSwitchTeam; -WhatIf shows what would happen without doing it.
263.5 Create and grow a team
- New-NetSwitchTeam needs -Name (not used by any switch or LBFO team) and -TeamMembers (at least one existing adapter not in another team).
- Add-NetSwitchTeamMember -Team <existing switch team> -Name <IfAlias>; a NetLbfo team name will not work; only wired adapters.
- The docs show no output for New-NetSwitchTeam, only syntax.
PowerShell
New-NetSwitchTeam -Name "SwitchTeam01" -TeamMembers "Ethernet 2","Ethernet 3"Add-NetSwitchTeamMember -Team "SwitchTeam01" -Name "Ethernet 2"263.6 Get-NetSwitchTeam and Get-NetSwitchTeamMember
- Get-NetSwitchTeam with no parameter returns all teams on the server; -Name accepts wildcards; -Member finds the team of a member object.
- Get-NetSwitchTeamMember returns the current adapter members of a team.
PowerShell
Get-NetSwitchTeamGet-NetSwitchTeam -Name "SwitchTeam01"Get-NetSwitchTeam -Name "SwitchTeam*"Get-NetSwitchTeamMember -Team "SwitchTeam01" -Name "Ethernet 2"263.7 Remove a member, rename, remove the team
- Remove-NetSwitchTeamMember: team and member must exist; syntax names the parameter -Name, the docs example writes -Member.
- Rename-NetSwitchTeam changes only the name; -Name must resolve to exactly one team; -NewName must be unused.
- Remove-NetSwitchTeam deletes the team (wildcards ok); no output by default, -PassThru returns the deleted object.
- After removal the members bind to the normal TCP/IP stack again, so run -WhatIf first.
PowerShell
Remove-NetSwitchTeamMember -Team "SwitchTeam01" -Member "Ethernet 2"Rename-NetSwitchTeam -Name "MyTeam1" -NewName "SwitchTeam01"Remove-NetSwitchTeam -Name "MyT*" -WhatIfGet-NetSwitchTeam -Name "SwitchTeam01" | Remove-NetSwitchTeam -PassThruRemove-NetSwitchTeam -Name "SwitchTeam01"| Cmdlet | Lifecycle step |
|---|---|
| New-NetSwitchTeam | Create the team |
| Add-NetSwitchTeamMember | Add an adapter |
| Get-NetSwitchTeam / Get-NetSwitchTeamMember | Inspect team and members |
| Remove-NetSwitchTeamMember | Take an adapter out |
| Rename-NetSwitchTeam | Change the name |
| Remove-NetSwitchTeam | Delete the team |
263.8 Lab: two links, one fails (Linux)
- Linux teaming uses the bonding/team drivers, which are kernel modules; creating a bond would auto-load one, so the lab uses a multipath route instead.
- server1 has nic1 and nic2 (veth) to switch1; one route to 192.168.63.100 with two nexthops.
- The kernel hashes each flow to one link: from .11 -> nic1, from .10 -> nic2.
Terminal
grep -cE '^(bonding|team) ' /proc/moduleszcat /proc/config.gz | grep -E 'BONDING|NET_TEAM|VETH|NET_NS|ROUTE_MULTI'Output
CONFIG_NET_NS=yCONFIG_IP_ROUTE_MULTIPATH=yCONFIG_BONDING=m# CONFIG_NET_TEAM is not setCONFIG_VETH=yTerminal
ip link add nic1 type veth peer name swp1ip link add nic2 type veth peer name swp2# server1: nic1 .2/30 nic2 .6/30ip route add 192.168.63.100/32 \ nexthop via 192.168.63.1 dev nic1 \ nexthop via 192.168.63.5 dev nic2for i in 10 11 12 13; do ip route get 192.168.63.100 from 192.168.63.$i | head -1; done- Step 1
1.Flow A (from .11) on nic1, flow B (from .10) on nic2
- Step 2
2.Both send 40 pings every 0.2 s
- Step 3
3.After 2 s: ip link set nic1 down
- Step 4
4.nic1 nexthop becomes dead linkdown
- Step 5
5.Flow A moves to nic2: 40/40 replies, no gap
- Step 6
6.nic1 up again -> flow A returns to nic1
Terminal
ping -D -i 0.2 -c 40 -I 192.168.63.11 192.168.63.100 & # flow A (nic1)ping -D -i 0.2 -c 40 -I 192.168.63.10 192.168.63.100 & # flow B (nic2)sleep 2ip link set nic1 downcat /sys/class/net/nic1/statistics/tx_packetscat /sys/class/net/nic2/statistics/tx_packetsOutput
40 packets transmitted, 40 received, 0% packet loss, time 8042ms40 packets transmitted, 40 received, 0% packet loss, time 8036ms[server1] counters before: nic1 tx 13 nic2 tx 13[server1] counters after: nic1 tx 31 nic2 tx 77- nic1 stopped at 18 more packets while nic2 rose by 64: flow A shifted automatically.
- Module list stayed at the same 22 names before and after the lab.
263.9 Common mistakes
- Thinking two links double the speed of a single flow: one flow stays on one link (hash); bandwidth gains need many flows.
- Putting both members on the same physical switch: if that switch dies, both links are gone.
- Passing a NetLbfo team name to Add-NetSwitchTeamMember.
- Removing a team without -WhatIf on a remote production server.
263.10 Interview tips
- NIC teaming = many physical NICs as one logical team, giving load balancing + failover.
- Windows options: NetSwitchTeam (switch-independent), NetLbfo (LACP/Static), SET on Hyper-V; Linux: bonding driver.
- One cable pulled = connection continues; spread members across switches to survive a switch failure.
- For a single flow the real benefit is failover, not double speed.