Create NIC team using all interfaces

I'm trying to put together a function that will take all the physical NICs on a server and team them together. I'm not even sure where I found the example, but here is the code I have below. This seems like it should be much simpler and that I'm missing something.

# Create a network team using switch independent teaming and Hyper-V port mode
Function TeamSetup ($teamName)
{
	$adapters = Get-NetAdapter
	$nicList = @()
	Foreach ($nic in $adapters)
	{
		$nicList += $nic.Name
	}
	New-NetLbfoTeam $teamName TeamMembers ($nicList) TeamNicName $teamName -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort
}

July 15th, 2014 6:08pm

Hi,

I have no way to test this, but the documentation states that you can use a wildcard pattern for -TeamMembers. Try using * by itself and see if that creates your team with every available adapter.

http://technet.microsoft.com/en-us/library/jj130847.aspx

If that doesn't work, join your $nicList together into a comma separated string and then use that for -TeamMembers ($nicList = $nicList -join ',').

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2014 7:21pm

This actually seems to be some sort of problem with running these commands as part of a script. If I enter my original code directly into PowerShell line-by-line, it works as expected. As does the same command using the * wildcard instead of the $nicList variable. No matter how I change the code in the script, it fails with this error:

New-NetLbfoTeam : There are no teamable NetAdapters on the system matching TeamMembers parameter
At C:\Script.ps1:190 char:2
+     New-NetLbfoTeam $teamName TeamMembers ($nicList) TeamNicName $teamName -T ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidArgument: (MSFT_NetLbfoTeam:root/StandardCimv2/MSFT_NetLbfoTeam) [New-NetLbfoTeam
], CimException + FullyQualifiedErrorId : MiClientApiError_InvalidParameter,New-NetLbfoTeam

July 16th, 2014 9:51am

I think I might see the issue, based on the error posted above.

Looks like your dashes in front of the parameters might be some different character that only looks like a dash until you try to use it.

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2014 9:58am

Well I'll be damned...

I rewrote that by hand from scratch at least twice and that didn't seem to fix it, but when I went to a function with dashes that was working and copy-and-pasted the dashes from there to the function having problems, it started working.

Really baffled as to how that happened, but it is working now, thanks for the help Mike!

July 16th, 2014 10:04am

Cheers, you're very welcome.

I ran into that issue myself many moons ago when I was using Word as a holding place for snippets. Word likes to automatically change the simple dash into something 'fancy'....

Just as an aside, the other major thing to watch out for when copy/pasting code is quotation marks. Lots of websites use smart quotes (bent quotes), which will also cause weird code breakages.

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2014 10:11am

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

Other recent topics Other recent topics