Automate network teaming
1 min read
I was asked to deploy a solution to have MDT create a network team on a physical server after deployment which did the following:
- Use part of the given hostname as host IP block
- Select 2 adapters which had a specific description (4 port adapter, 2x SFP+ and 2x 1Gbit base-T)
- Disable other unused adapters
Selecting the host IP address: example “SRV24APP”
$Computername = Hostname
Note: in this case I used part of the computername (24), it would also work to create a TXT/CSV file containing all hostnames and required addresses and import this file from the DeploymentShare$
$HostIP = $Computername -replace “[^0-9]”
$TeamIPAddress = “192.168.0.”+$HostIP
Getting the required network team members:
$TeamMembers = Get-NetAdapter | where{$_.InterfaceDescription -like “Broadcom NetXtreme E-Series Advanced Dual-port 10Gb SFP+ Ethernet Network Daughter Card*”} | select Name
Creating the network team:
New-NetLbfoTeam -Name “Team name” -TeamMembers $TeamMembers[0].Name,$TeamMembers[1].Name -TeamingMode LACP -LoadBalancingAlgorithm Dynamic
Configure the required IPv4 settings:
get-netadapter “Team name” | New-NetIPAddress -IPAddress $TeamIPAddress -AddressFamily IPv4 -PrefixLength 24 -defaultgateway “192.168.0.1”
Configuring DNS:
Get-NetAdapter “Team name” | Set-DnsClientServerAddress -ServerAddresses “192.168.0.1”,”192.168.0.2″
Disable all other adapters which were present on the physical NIC:
Get-netadapter | where{$_.InterfaceDescription -like “Broadcom NetXtreme Gigabit Ethernet*”} | Disable-Netadapter -confirm:$False
Register the new interface on the set up DNS server:
Register-DnsClient