Freigeben über


Using PowerShell to Easily Build LBFO teams

Here's an interesting challenge.  It's not actually DIFFICULT but it is OH so IRRITATING on any operating system.

I want to Team up some network cards for Load Balancing.     So I pick two at the back of the server,  try to figure out which two it is that lit up, then remember those two (or actually more sometimes) to make them into a team.

In Server 2012 we have had the ability to build these teams.

The challenge is still there.   "How to identify and build the team"

PowerShell makes this so must easier.    We can use PowerShell to FIRST identify cards that are attached to a live switch using the Get-NetAdapter Cmdlet.   Using the following line I can see only the PHYSICAL adapters (vs VPN, Hyper-V and others)

Get-NetAdapter -Physical

I can also examine the properties of this adapter and say "Show me only the ones that are connected"

Get-NetAdapter -Physical | Where-Object { $_.Status -ne 'Disconnected' }

What this means, at the VERY least is I have a way of seeing what wires are already connected as an object and having PowerShell tell me after (if I want) who was added.  We can do this easily by grabbing and Storing the Name of all the Network connections already attached.

$ExistingName=Get-NetAdapter -Physical | Where-Object { $_.Status -ne 'Disconnected' } | Select-object Name

We can then obtain and store (After attaching the new lan cables) a set of Network Cards that have been added.  We can compare and use a -notcontains to compare the original array and the new array.

$AllNetworkCards=Get-NetAdapter -Physical | Where-Object { $_.Status -ne 'Disconnected' }

$NewNetworkCards=$AllNetworkCards | Where-object { $_.Name -notcontains $ExistingName.Name }

We now, without trying to REMEMBER what network cards we attached, have a way to track them.

At this point, if you wanted to create a network team you could simply do this

New-NetLBFOTeam -name 'LBFOTeamTest' -teammembers ($NewNetworkCards.Name) -confirm:$False

A neat little trick in PowerShell.    I hope this helps you in all your Network teaming tasks :)

Cheers

Sean
The Energized Tech
Microsoft PFE