Windows NIC Teaming using PowerShell (Part 4)

If you would like to read the other parts in this article series please go to:

Introduction

Now that we’ve examined what Windows NIC Teaming is, how it works, what scenarios it supports, and what considerations matter when implementing it, we can finally move forward and look at how to implement it using Windows PowerShell. We’ll begin by examining how to do this on a physical server and then in the next article we’ll look at how to do it in a virtual machine.

Test environment

For my test environment I’m using an old Dell T300 server that has two built-in GbE network adapters. I’ve performed a clean install of Windows Server 2012 R2 on the server and am logged on as Administrator. The server is on a test network that has another server deployed as the domain controller, DNS server and DHCP server for the contoso.com Active Directory domain. I didn’t have a spare Gigabit Ethernet switch in my lab so I’m using a 100 Mbps Fast Ethernet switch instead, so the server’s built-in network adapters autonegotiate 100 Mbps link speeds.

Examining the initial network configuration

Let’s use Windows PowerShell to examine the initial network configuration of the server. The Get-NetAdapter cmdlet can be used to display the available network adapters as follows:

PS C:\> Get-NetAdapter

Name                      InterfaceDescription        ifIndex                         Status          MacAddress                  LinkSpeed
—-                          ——————–                ——-                            ——              ———-                          ———
Ethernet 2                Broadcom NetXtreme    Gigabit Ethernet #2     13 Up           A4-BA-DB-0A-96-0C     100 Mbps
Ethernet                  Broadcom NetXtreme     Gigabit Ethernet          12 Up           A4-BA-DB-0A-96-0B     100 Mbps

We can use the -Physical option to make sure these are physical adapters not virtual ones:

PS C:\> Get-NetAdapter -Physical

Name                      InterfaceDescription           ifIndex                          Status       MacAddress                 LinkSpeed
—-                           ——————–                   ——-                             ——       ———-                            ———
Ethernet 2               Broadcom NetXtreme        Gigabit Ethernet #2      13 Up     A4-BA-DB-0A-96-0C       100 Mbps
Ethernet                  Broadcom NetXtreme        Gigabit Ethernet           12 Up     A4-BA-DB-0A-96-0B       100 Mbps

Here’s another way of doing this:

PS C:\> Get-NetAdapter -Name “Ethernet” | Format-List -Property Virtual

Virtual : False

We can use the Get-NetIPInterface cmdelt to list all network interfaces that start with the word “Ethernet” and verify they’re using DHCP to acquire their IP addresses:

PS C:\> Get-NetIPInterface -InterfaceAlias “Ethernet*”  -AddressFamily IPv4 | Format-Table InterfaceAlias, ifIndex, Dhcp  -AutoSize

InterfaceAlias     ifIndex   Dhcp
————–          ——-     —-
Ethernet 2         13          Enabled
Ethernet            12          Enabled

We can use the Get-NetIPAddress cmdelt to display the IP addresses and subnet mask (via prefix length) assigned by DHCP to each adapter:

PS C:\> Get-NetIPAddress -InterfaceAlias “Ethernet*” -AddressFamily IPv4 | Format-List InterfaceAlias, ifIndex, IPAddress, PrefixLength

InterfaceAlias : Ethernet 2
ifIndex        : 13
IPAddress      : 172.16.11.61
PrefixLength   : 24

InterfaceAlias : Ethernet
ifIndex        : 12
IPAddress      : 172.16.11.62
PrefixLength   : 24

PowerShell cmdlets for Windows NIC teaming

NetLbfo is the name of the PowerShell module for Windows NIC Teaming. You can use the Get-Command cmdlet to display a list of all cmdlets in this module as follows:

PS C:\> Get-Command -Module NetLbfo

CommandType     Name                                               ModuleName
———–                —-                                                    ———-
Function        Add-NetLbfoTeamMember                     NetLbfo
Function        Add-NetLbfoTeamNic                             NetLbfo
Function        Get-NetLbfoTeam                                   NetLbfo
Function        Get-NetLbfoTeamMember                      NetLbfo
Function        Get-NetLbfoTeamNic                              NetLbfo
Function        New-NetLbfoTeam                                  NetLbfo
Function        Remove-NetLbfoTeam                            NetLbfo
Function        Remove-NetLbfoTeamMember               NetLbfo
Function        Remove-NetLbfoTeamNic                       NetLbfo
Function        Rename-NetLbfoTeam                            NetLbfo
Function        Set-NetLbfoTeam                                    NetLbfo
Function        Set-NetLbfoTeamMember                       NetLbfo
Function        Set-NetLbfoTeamNic                               NetLbfo

We can use the Get-NetLbfoTeam to verify that there is currently no team created:

PS C:\> Get-NetLbfoTeam
PS C:\>

Creating a new team

The New-NetLbfoTeam cmdlet can be used to create a new team. Here’s how we could create a new team that includes both physical network adapters on the server:

PS C:\> New-NetLbfoTeam -Name TestTeam -TeamMembers “Ethernet”, “Ethernet 2” -WhatIf

What if: Creates Team:’TestTeam’ with TeamMembers:{‘Ethernet’, ‘Ethernet 2′}, TeamNicName:’TestTeam’, TeamingMode:’SwitchIndependent’ and LoadBalancingAlgorithm:’Dynamic’.

The above command illustrates the handy use of the -WhatIf option which lets you see what a PowerShell command will do before you actually execute it.

As the next command illustrates, you can also create a new team that includes only one network adapter:

PS C:\> New-NetLbfoTeam -Name TestTeam -TeamMembers “Ethernet” -WhatIf

What if: Creates Team:’TestTeam’ with TeamMembers:{‘Ethernet’}, TeamNicName:’TestTeam’, TeamingMode:’SwitchIndependent’ and LoadBalancingAlgorithm:’Dynamic’.

Let’s actually do that as it’ll allow us to add the second adapter to the team later:

PS C:\> New-NetLbfoTeam -Name TestTeam -TeamMembers “Ethernet”

Confirm
Are you sure you want to perform this action?
Creates Team:’TestTeam’ with TeamMembers:{‘Ethernet’}, TeamNicName:’TestTeam’, TeamingMode:’SwitchIndependent’ andLoadBalancingAlgorithm:’Dynamic’.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is “Y”): y

Name                   : TestTeam
Members                : Ethernet
TeamNics               : TestTeam
TeamingMode            : SwitchIndependent
LoadBalancingAlgorithm : Dynamic
Status                 : Down

The last line above (Status equals Down) looks a bit ominous, so let’s go into the GUI and see what’s happening with our new NIC team:

Image
Figure 1: A new NIC team with one network adapter as a member.

The figure shows that the status of both the team and the adapter in it are both Active, so let’s run Get-NetLbfoTeam to get more info about the new team:

PS C:\> Get-NetLbfoTeam

Name                   : TestTeam
Members                : Ethernet
TeamNics               : TestTeam
TeamingMode            : SwitchIndependent
LoadBalancingAlgorithm : Dynamic
Status                 : Up

This time the Status shows as Up which is what we were hoping for, so the previous Status of Down must have been a temporary anomaly that resulted from network interruption when the new team was created.

Let’s use the Get-NetLbfoTeamMember cmdlet to verify that our new team has only one member in it:

PS C:\> Get-NetLbfoTeamMember -Team TestTeam

Name                          : Ethernet
InterfaceDescription   : Broadcom NetXtreme Gigabit Ethernet
Team                         : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Active
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : NoFailure

We can also use Get-NetLbfoTeamNic to get information about the interfaces defined for the team:

PS C:\> Get-NetLbfoTeamNic -Team TestTeam

Name                    : TestTeam
InterfaceDescription    : Microsoft Network Adapter Multiplexor Driver
Team                    : TestTeam
VlanID                  :
Primary                 : True
Default                 : True
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100

Adding a member to a team

Now let’s use the Add-NetLbfoTeamMember cmdlet to add our second network adapter to the new team. We’ll use Whatiff first to make sure we’re doing it right:

PS C:\> Add-NetLbfoTeamMember -Name “Ethernet 2” -Team TestTeam -WhatIf

What if: Adds the Member:’Ethernet 2′ with AdministrativeMode:’Active’ to the Team:’TestTeam’

Let’s go ahead and add the second adapter to the team:

PS C:\> Add-NetLbfoTeamMember -Name “Ethernet 2” -Team TestTeam

Confirm
Are you sure you want to perform this action?
Adds the Member:’Ethernet 2′ with AdministrativeMode:’Active’ to the Team:’TestTeam’
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is “Y”): y

Name                    : Ethernet 2
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet #2
Team                    : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Failed
TransmitLinkSpeed(Mbps) : 0
ReceiveLinkSpeed(Mbps)  : 0
FailureReason           : PhysicalMediaDisconnected

Again it looks like something went wrong, so let’s go into the GUI and see what our team looks like now:

Image
Figure 2: The team now has two adapters as members.

Everything looks good so let’s run Get-NetLbfoTeam again to get more info about the team:

PS C:\> Get-NetLbfoTeam

Name                   : TestTeam
Members                : {Ethernet 2, Ethernet}
TeamNics               : TestTeam
TeamingMode            : SwitchIndependent
LoadBalancingAlgorithm : Dynamic
Status                 : Up

The Status of the team is Up, so everything is OK. Let’s check on the status of the members of the team:

PS C:\> Get-NetLbfoTeamMember -Team TestTeam

Name                    : Ethernet 2
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet #2
Team                    : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Active
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : NoFailure

Name                    : Ethernet
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet
Team                    : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Active
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : NoFailure

Let’s also see what we can find out about the interface for the team:

PS C:\> Get-NetLbfoTeamNic -Team TestTeam

Name                    : TestTeam
InterfaceDescription    : Microsoft Network Adapter Multiplexor Driver
Team                    : TestTeam
VlanID                  :
Primary                 : True
Default                 : True
TransmitLinkSpeed(Mbps) : 200
ReceiveLinkSpeed(Mbps)  : 200

Note that the link speed is double what either adapter can provide alone, so we’ve got a team!

Configuring failover

Now let’s say that we’ve decided to configure our team for failover instead of link aggregation. Specifically, the team will use the “Ethernet” network adapter by default and if “Ethernet” fails then the “Ethernet 2” network adapter will take over to ensure availability for our server on the network. We can do this by using the Set-NetLbfoTeamMember cmdlet as follows:

PS C:\> Set-NetLbfoTeamMember -Name “Ethernet 2” -AdministrativeMode Standby -WhatIf

What if: Changes the AdministrativeMode for Member:’Ethernet 2′ from ‘Active’ to ‘Standby’ in Team:’TestTeam’.

Now let’s do it:

PS C:\> Set-NetLbfoTeamMember -Name “Ethernet 2” -AdministrativeMode Standby
PS C:\>

We can use Get-NetLbfoTeamMember to verify the configuration change as follows:

PS C:\> Get-NetLbfoTeamMember -Team TestTeam

Name                    : Ethernet 2
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet #2
Team                    : TestTeam
AdministrativeMode      : Standby
OperationalStatus       : Standby
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : AdministrativeDecision

Name                    : Ethernet
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet
Team                    : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Active
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : NoFailure

Note that the operational status of the “Ethernet 2” network adapter shown above displays as Standby. The GUI shows us the same thing:

Image
Figure 3: “Ethernet 2” is now a standby adapter

To test this, we’ll now disconnect the network cable from the “Ethernet” adapter (the active adapter) and see what happens to the “Ethernet 2” adapter (the standby adapter) as a result of our action. Here’s what Get-NetLbfoTeamMember shows after performing this action:

PS C:\> Get-NetLbfoTeamMember -Team TestTeam

Name                    : Ethernet 2
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet #2
Team                    : TestTeam
AdministrativeMode      : Standby
OperationalStatus       : Active
TransmitLinkSpeed(Mbps) : 100
ReceiveLinkSpeed(Mbps)  : 100
FailureReason           : NoFailure

Name                    : Ethernet
InterfaceDescription    : Broadcom NetXtreme Gigabit Ethernet
Team                    : TestTeam
AdministrativeMode      : Active
OperationalStatus       : Failed
TransmitLinkSpeed(Mbps) : 0
ReceiveLinkSpeed(Mbps)  : 0
FailureReason           : PhysicalMediaDisconnected

Note that “Ethernet 2” now shows up as operationally active, so failover has indeed occurred and can be verified in the GUI:

Image
Figure 4: The standby adapter has become active.

Now let’s reconnect the network cable to the “Ethernet” adapter and see what happens. Here’s what the GUI shows immediately after performing this action:

Image
Figure 5: The failed adapter has been restored and the team is being reconfigured.

A few seconds later the GUI looks like this:

Image
Figure 6: The team has been restored.

Notice that it takes a few seconds for everything to work again.               

Let’s change team member “Ethernet 2” from standby back to active so we can use the team for link aggregation instead of failover:

PS C:\> Set-NetLbfoTeamMember -Name “Ethernet 2” -AdministrativeMode Active
PS C:\>

One final thing: let’s run ipconfig and see what the IP address configuration of the two physical network adapters on our server look like after creating a team from them:

PS C:\> ipconfig

Windows IP Configuration

Ethernet adapter TestTeam:

   Connection-specific DNS Suffix  . : contoso.com
   Link-local IPv6 Address . . . . . : fe80::69e3:4408:7d3f:ac4d%25
   IPv4 Address. . . . . . . . . . . : 172.16.11.62
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.11.1

Tunnel adapter isatap.contoso.com:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : contoso.com

Notice that instead of displaying our two adapters the ipconfig command displays the IP address configuration of the team that was created from the adapters. Notice also that the IP address of the team is the same as what the primary team member (“Ethernet”) had as its configuration before the new team was created. When you create a new team, one of the team members is assigned the role of primary team member like this, and the MAC address for the team is the MAC address of the network adapter used for this primary team member. This is useful knowledge if you ever need to perform a network trace to troubleshoot an issue involving a NIC team.

If you would like to read the other parts in this article series please go to:

About The Author

1 thought on “Windows NIC Teaming using PowerShell (Part 4)”

  1. NIC Teaming using PowerShell – it should be called 4 pages of nonsense and GUI’s and so far no mention of even launching PowerShell let alone what commands you use to set up NIC Teaming – very misleading title #clickbait

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top