Moving right along this PowerShell theme I have been working a bit is writing a script that would build me an LBFO team.
For those of you that have not heard of an LBFO team – lets just say that you will love it. In-the-box NIC teaming.
Yes! Windows Server 2012 has in-box NIC teaming. The term is LBFO – Load Balancing FailOver. You will need that to find the cmdlets.
You can create an LBFO team using Server Manager – it is quick, painless, works well.
With PowerShell I will simply guide you past the problem that I kept tripping over. And that is sending your list of NIC aliases in as an array of strings.
Back to what I am doing. I got all fancy with my one liner for selecting my NICs.
That is another post.
But, now that I have that list of NICs – it is the interface alias that is the important part. That is what the New-NetLBFOTeam cmdlet wants.
Once you have that, it is really simple.
$team = New-NetLbfoTeam -Name $name -TeamNicName ($name ) -TeamMembers ($nicList) -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false
On a side note: the default LoadBalancingAlgorithm is TransportPorts and works in most general cases. If the team is specific to supporting VMs and it has an External Virtual Switch attached then HyperVPort should be used.
This has been discussed in the //BUILD/ presentations that are so frequently referenced.
Now, if you have gotten used to Hyper-V VM objects you know that those are ‘live’ – this is not the case with the networking objects.
So, if you want your script to wait until the team is ‘up’ you need a bit of a loop. I did it this way, a simple Do Until testing for the status to change to Up.
Do {$team = Get-NetLbfoTeam -Name $team.Name
sleep 2}
until ($team.Status -eq "Up")
Notice that I need to keep querying the team.
You will recall that Hyper-V PowerShell objects are ‘live’ – that is; you grab a VM object, change it, and the object that you already had is updated. Not the case here, this is much more like CIM / WMI – where you have to do something then check on it.
No comments:
Post a Comment