Windows 2012 R2 Teaming Script problem RRS feed

  • Question

  • Trying to script for an Auto build the Teaming of NICs in 2012 R2 Server, I'm running into a problem trying to assign the IP address to the new Teamed NIC using WMI.  What am I missing?

      I had just added the split for the DNS string, I haven't tested that yet, the problem is with the WMI methods to write the IP to the new NIC, I'm getting result values of 70 for the IP, (Invalid IP address).
    [String]$TeamingDesc = "Microsoft Network Adapter Multiplexor Driver"
    [Array]$GWMetric = 1
    #[String]$IP = ""
    #[String]$SubN = ""
    #[String]$GW = ""
    #[String]$DNS = ""
    #[String]$WinsPrimary = ""
    #[String]$WinsSecondary = ""
        $ipaddress = Get-WmiObject win32_networkadapterconfiguration -filter "DHCPEnabled = 'False'"
            [Array]$IP = $ipaddress.Ipaddress
            [Array]$SubN = $ipaddress.IPSubnet
            [Array]$GW = $ipaddress.DefaultIPGateway
            [String]$DNS = $ipaddress.DNSServerSearchOrder
            [Array]$WinsPrimary = $ipaddress.WINSPrimaryServer
            [Array]$WinsSecondary = $ipaddress.WINSSecondaryServer
            [Array]$DNSSplit = $DNS.split(" ")
            Write-Host $IP
            Write-Host $SubN
            Write-Host $GW
            Write-Host $DNS
            Write-Host $DNSSplit[0]
            Write-Host $DNSSplit[1]
        $Interfacename = @()
        $ConnectedNics = Get-NetIPInterface -ConnectionState Connected | where {$_.InterfaceAlias -Match "Ethernet*"}
            foreach($line in $ConnectedNics){
                $Interfacename += $line.InterfaceAlias
        New-NetLbfoTeam -Name ProdTeam -TeamMembers $Interfacename[0],$Interfacename[1] -TeamingMode SwitchIndependent -Confirm:$false
        Set-NetLbfoTeamMember -Name "$Interfacename[1]" -AdministrativeMode Standby
        $TeamedNic = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "Description = 'Microsoft Network Adapter Multiplexor Driver'"    
            $TeamedNic.EnableStatic("$IP", "$SubN")
            $TeamedNic.SetGateways($GW, 1)

    The Write-Host stmts are in there for debugging..

    Thank you,


    • Edited by Bryan99 Thursday, June 5, 2014 5:24 PM
    Thursday, June 5, 2014 5:19 PM


  • Found the issue with some local help. The WMI query "$ipaddress = Get-WmiObject win32_networkadapterconfiguration -filter "DHCPEnabled = 'False'"  " was adding extra stuff to the arrays.  I was finding that the actual IP information was at position 8 $IP[7], so I had to modify my WMI query to this:  "

    $ipaddress=Get-WmiObjectwin32_networkadapterconfiguration-filter"DHCPEnabled = 'False' and IPEnabled = True"

    "  Apparently I was getting junk form virtual adapters.
    • Marked as answer by Bryan99 Thursday, June 5, 2014 6:48 PM
    Thursday, June 5, 2014 6:48 PM