Help required with getting all NICs on a server and passing that as a variable to New-Lbfoteam

Hi

I'm hoping someone can give me some pointers on a particular issue i'm facing with a script i've written.

Ideally the script will form part of an MDT task sequence to build and configure Hyper-V hosts but I need to get it working first!

Essentially I want the script to configure a hyper-v host with all pNIC's configured in a team but I'm strugging on how to acheive this.

I've done:

$NICs=Get-NetAdapter -Physical

Which correctly lists the pNIC's however what I want the script to then do is for each pNIC found pass that to the following:

New-NetLbfoTeam -Name PhysicalTeam -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic -TeamMembers "each physical NIC found on the server"

I know I probably need something like a foreach-object ($NIC in $NICs) statement after the Get-NetAdapter  but I cant get my head around how best to acheive this

Thanks in advance

May 28th, 2015 7:36am

Hi Jack,

I can't test this, but based on the documentation the cmdlet wants a comma separated list of NIC names. You could do something like this to get that list:

$nicList = (Get-NetAdapter -Physical).Name -join ','

$nicList

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 9:19am

Just do it:

#
$NICs=Get-NetAdapter -Physical
New-NetLbfoTeam -Name PhysicalTeam -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic -TeamMembers $NICs


May 28th, 2015 9:50am

Thanks but this gives me the error:

New-NetLbfoTeam: Cannot process argument transformation on Parameter 'TeamMembers'. Cannot convert the MSFT_NetAdapter (CreationClassName= "MSFT_NetAdapter", DeviceID = "(DEDD2EFA-OC61-4C45-811A-715B4AA4E6AB)", SystemCreationClassName = "CIM_NetworkPort" value of type Microsoft.Management.Infrastructure.CimInstance#ROOT/StandardCimv2/MSFT_NetAdapter to type "System.Management.Automation.WildcardPattern"

Any ideas?

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 12:33pm

This looks promising however when I pass the variable to New-NetlbfoTeam I get:

"There are no teamable NetAdapters on the system matching TeamMembers parameter"

Adding the NIC name manually does work though

June 3rd, 2015 12:35pm

It expects a wildcard such as myadapter* for Myadapter1, myadapter2

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 12:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics