#obtaining the EthernetAdapters located on the local machine $colItems = @() $colItems += get-wmiobject -Amended -class "IANet_PhysicalEthernetAdapter" -namespace "root\intelncs2" -Computername "." -Filter "StatusInfo = 3" #get the instance of IANet_NetService $service = Get-WmiObject -class IANet_NetService -Namespace "root\intelncs2" #get the lock object to make changes $lockobj = $service.beginApply() #Write-Host "Got the lock: "+ $lockobj.ClientSetHandle #this is necessary to set the lock into a new object $context = new-object System.Management.ManagementNamedValueCollection #adding a new single named value to the collection with the value of the lock objects client handle $context.Add('ClientSetId', [int]$lockobj.ClientSetHandle) #the invoke options $invokeoptions = New-Object System.Management.InvokeMethodOptions $invokeoptions.Context = $context # here we are just using the 1st 2 devices to be placed in the team $adapterstoteam = @() $adapterstoteam += $colItems[0] $adapterstoteam += $colItems[1] # creating an AFT team with a name of "TEAM1" # 0 - Adapter Fault Tolerance # 1 - Adaptive Load Balancing # 2 - Static Link Aggregation # 4 - IEEE 802.3ad Dynamic Link Aggregation # 5 - Switch Fault Tolerance # 6 - Virtual Machines Load Balancing $TeamingMode = 0 $TeamName = "TEAM1" $classdef = New-Object System.Management.ManagementClass root\intelncs2:IANet_TeamOfAdapters $classdef.Options.UseAmendedQualifiers = $true $classdef.Options.Context = $context #fill in the CreateTeam's method parameters $param = $classdef.psbase.GetMethodParameters("CreateTeam") $param.Adapters = [string[]]$adapterstoteam $param.TeamingMode = [UInt32]$TeamingMode $param.TeamName = [string]$TeamName #call the CreateTeam method to create the new team $value = $classdef.psbase.InvokeMethod("CreateTeam", $param, $invokeoptions) #finally call Apply to release the lock object $inparams = $Service.psbase.GetMethodParameters("Apply") $inparams.ClientSetHandle=[int]$lockobj.ClientSetHandle $result = $Service.psbase.InvokeMethod("Apply",$inparams,$null)