Pergunta

I'm trying to automate the create of a NIC team during an unattended Windows Server 2012 R2 install. I've got the following PowerShell code:

New-NetLbFoTeam -Name "LANTeam" -TeamMembers "Ethernet", "Ethernet 2" -TeamNicName "LAN" -TeamingMode SwitchIndependent -LoadBalancingAlgorithm TransportPorts -Confirm:$false -ErrorAction SilentlyContinue

That works well for my Dell servers, but the HP servers Windows randomly gives InterfaceAliases to. One install Ethernet 2 could be the Broadcom, the next it could be the NC373i card.

What I'm trying to accomplish is set the -TeamMembers parameter to be the two NICs that match "HP NC373i*" wildcard for the InterfaceDescription, or have a valid DHCP address. The other team I'll do something similar, but don't retrieve a valid IP address.

I've tried setting a hash table, but not getting it to stick in there correctly.

Any assistance would be greatly appreciated!

Nenhuma solução correta

Outras dicas

I was able to figure it out on my own. I output the get-netadapter output to a variable, and added that:

$adapters = Get-netAdapter –InterfaceDescription “HP NC*”

$nicList = @()
Foreach ($nic in $adapters) {$nicList += $nic.Name}

$team = New-NetLbfoTeam -Name “LANTeam” -TeamNicName “LAN” -TeamMembers ($nicList) -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top