PS Script to Automate NIC Teaming and Configure Static IP Address based off an Existing Physical NIC

# Retrieve IP Address and Default Gateway from static IP Assigned NIC and assign to variables.
$wmi = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled = True" |
Where-Object { $_.IPAddress -match '192\.' }
$IPAddress = $wmi.IpAddress[0]
$DefaultGateway = $wmi.DefaultIPGateway[0]
# Create Lbfo TEAM1, by binding “Ethernet” and “Ethernet 2” NICs.
New-NetLbfoTeam -Name TEAM1 -TeamMembers "Ethernet","Ethernet 2" -TeamingMode Lacp -LoadBalancingAlgorithm TransportPorts -Confirm:$false
# 20 second pause to allow TEAM1 to form and come online.
Start-Sleep -s 20
# Configure static IP Address, Subnet, Default Gateway, DNS Server IPs to newly formed TEAM1 interface.
New-NetIPAddress –InterfaceAlias “TEAM1” –IPAddress $IPAddress –PrefixLength 24 -DefaultGateway $DefaultGateway
Set-DnsClientServerAddress -InterfaceAlias “TEAM1” -ServerAddresses xx.xx.xx.xx, xx.xx.xx.xx
Howdy All!
I was recently presented with the challenge of automating the creation and configuration of a NIC Team on Server 2012 and Server 2012 R2.
Condition:
New Team will use static IP Address of an existing NIC (one of two physical NICs to be used in the Team).  Each server has more than one NIC.
Our environment is pretty static, in the sense that all our servers use the same subnet mask and DNS server IP Addresses, so I really only had
to worry about the Static IP Address and the Default Gateway.
1. Retrieve NIC IP Address and Default Gateway:
I needed a way to query only the NIC with the correct IP Address settings and create required variables based on that query.  For that, I
leveraged WMI.  For example purposes, let's say the servers in your environment start with 192. and you know the source physical NIC with desired network configurations follows this scheme.  This will retrieve only the network configuration information
for the NIC that has the IP Address that starts with "192."  Feel free to replace 192 with whatever octet you use.  you can expand the criteria by filling out additional octects... example:
Where-Object
$_.IPAddress
-match'192\.168.' } This would search for NICs with IP Addresses 192.168.xx.xx.
$wmi
= Get-WmiObject
Win32_NetworkAdapterConfiguration
-Filter "IPEnabled = True"
|
Where-Object {
$_.IPAddress
-match '192\.' }
$IPAddress
= $wmi.IpAddress[0]
$DefaultGateway
= $wmi.DefaultIPGateway[0]
2. Create Lbfo TEAM1
This is a straight forward command based off of New-NetLbfoTeam.  I used  "-Confirm:$false" to suppress prompts. 
Our NICs are named “Ethernet” and “Ethernet 2” by default, so I was able to keep –TeamMembers as a static entry. 
Also added start-sleep command to give the new Team time to build and come online before moving on to network configurations. 
New-NetLbfoTeam
-Name TEAM1
-TeamMembers "Ethernet","Ethernet 2"
-TeamingMode SwitchIndependent
-LoadBalancingAlgorithm
Dynamic -Confirm:$false
# 20 second pause to allow TEAM1 to form and come online.
Start-Sleep
-s 20
3. Configure network settings for interface "TEAM1".
Now it's time to pipe the previous physical NICs configurations to the newly built team.  Here is where I will leverage
the variables I created earlier.
There are two separate commands used to fully configure network settings,
New-NetIPAddress : Here is where you assign the IP Address, Subnet Mask, and Default Gateway.
Set-DnsClientServerAddress: Here is where you assign any DNS Servers.  In my case, I have 2, just replace x's with your
desired DNS IP Addresses.
New-NetIPAddress
–InterfaceAlias “TEAM1”
–IPAddress $IPAddress
–PrefixLength 24
-DefaultGateway $DefaultGateway
Set-DnsClientServerAddress
-InterfaceAlias “TEAM1”
-ServerAddresses xx.xx.xx.xx, xx.xx.xx.xx
Hope this helps and cheers!

I've done this before, and because of that I've run into something you may find valuable. 
Namely two challenges:
There are "n" number of adapters in the server.
Adapters with multiple ports should be labeled in order.
MS only supports making a LBFO Team out of "like speed" adapters.
To solve both of these challenges I standardized the name based on link speed for each adapter before creating hte team.  Pretty simple really!  FIrst I created to variables to store the 10g and 1g adapters.  I went ahead and told it to skip
any "hyper-V" ports for obvious reasons, and sorted by MAC address as servers tend to put all thier onboard NICs in sequentially by MAC:
$All10GAdapters = (Get-NetAdapter |where{$_.LinkSpeed -eq "10 Gbps" -and $_.InterfaceDesription -notmatch 'Hyper-V*'}|sort-object MacAddress)
$All1GAdapters = (Get-NetAdapter |where{$_.LinkSpeed -eq "1 Gbps" -and $_.InterfaceDesription -notmatch 'Hyper-V*'}|sort-object MacAddress)
Sweet ... now that I have my adapters I can rename them into something standardized:
$i=0
$All10GAdapters | ForEach-Object {
Rename-NetAdapter -Name $_.Name -NewName "Ethernet_10g_$i"
$i++
$i = 0
$All1GAdapters | ForEach-Object {
Rename-NetAdapter -Name $_.Name -NewName "Ethernet_1g_$i"
$i++
Once that's done Now i can return to your team command but use a wildcard sense I know the standardized name!
New-NetLbfoTeam -Name TEAM1G -TeamMembers Ethernet_1g_* -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic -Confirm:$false
New-NetLbfoTeam -Name TEAM10G -TeamMembers Ethernet_10g_* -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic -Confirm:$false

Similar Messages

  • 2012 R2 NIC Teaming and netwroking

    I have a 4 port NIC, all connected to the same network using DHCP, when I team two cards, they no longer have an IP address. Is that by design?
    Where can I find more information about the virtual networking how to?
    TIA

     
    Yes it is by design.
    If individual NICs are configured with IP settings and then you create a NIC teaming the individual nics will lose their IP settings.
    And you will no longer be able to configure the ip settings on the individual NICs which are part of a NIC team. Instead you will need to assign the ip address on the NIC Team.
    To assign ip address to the NIC teams, go to control Panel\ Network and Internet\ Network Connections
    To assign VLANs and manage/update Team interfaces: In the Server Manager select the local server and then in the local server properties section click on Nic Teaming "Enabled" link.
    This will open the NIC teaming window and here you can manage the NIC teams.
    For more information on NIC teams please refer to:
    http://blogs.technet.com/b/keithmayer/archive/2012/11/20/vlan-tricks-with-nic-teaming-in-windows-server-2012.aspx
    Kind Regards Tim (Canberra)

  • Windows Server 2012 R2 NIC Teaming and DHCP Issue

    Came across a weird issue today during a server deployment. I was doing a physical server deployment and got Windows installed and was getting ready to connect it to our network. Before connecting the Ethernet cables to the network adapters, I created a
    NIC Team using Windows Server 2012 R2 built-in software with a static IP address (we'll say its 192.168.1.56). Once I plugged in the Ethernet cables, I got network access but was unable to join our domain. At this time, I deleted the NIC team and the two network
    adapters got their own IP addresses issued from DHCP (192.168.1.57 and 192.168.1.58) and at this point I was able to join our domain. I recreated the NIC team and set a new static IP (192.168.1.57) and everything was working great as intended.
    My issue is when I went into DHCP I noticed a random entry that was using the IP address I used for the first NIC teaming attempt (192.168.1.56), before I joined it to the domain. I call this a random entry because it is using the last 8 characters of the
    MAC address as the hostname instead of the servers hostname.
    It seems when I deleted the first NIC team I created (192.168.1.56), a random MAC address Server 2012 R2 generated for the team has remained embedded in the system. The IP address is still pingable even though an ipconfig /all shows the current NIC team
    with the IP 192.168.1.57. There is no IP address of 192.168.1.56 configured on the current server and I have static IPs set yet it is still pingable and registering with DHCP.
    I know this is slightly confusing but I am hoping someone else has encountered this issue and may be able to tell me how to fix this. Simply deleting the DHCP entry does not do the trick, it comes back.

    Hi,
    Please confirm you have choose the right NIC team type, If you’ve previously configured NIC teaming, you’re aware NIC teams usually require the assistance of network-side
    protocols. Prior to Windows 2012, using a NIC team on a server also meant enabling protocols like EtherChannel or LACP (also known as 802.1ax or 802.3ad) on network ports.
    More information:
    NIC teaming configure in Server 2012
    http://technet.microsoft.com/en-us/magazine/jj149029.aspx
    Hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Correct binding order in a Cluster with logical switches, NIC teams, and vNICs on the host.

    I have seen many recommendations to set the network binding order on you Hyper-V hosts to something similar to:
    Management NIC
    Cluster NICs
    iSCSI NICS
    However, all of  these recommendations are for scenarios where the NICs are all physical NICs in the host.
    Using Server 2012 R2, I am building converged networks with logical switches, NIC Teams, and vNICs on the host.  So when I go set the network binding order, I now have all these components to deal with as well.  For example, on a 4 adapter blade,
    I might typically have the following items in the binding order drop-down.
    4 - physical NICs (2- teamed for the 1 virtual switch, the other 2 used for iSCSI)
    1 - Team interface (Datacenter_Switch)
    5 - vNICs (Management, Cluster, LiveMigration, iSCSI-1, iSCSI-2)
    So, should you only worry about order of the vNICS (placed at the top) and let the other components just fall to the bottom of the list?  This seems to be likely to me, since the binding order applies to service access to the resources, and the other
    components are not being directly accessed by network services?
    Or, should the order start out with the physical resources needed to access the vNICs, followed by any intermediate resources (switches or team interfaces, then the vNICS themselves, to ensure that the resources are available to the subcompnents accessing
    them?
    Any help would be appreciated.
    Thanks.
    -Tim Reid

    If by 'network binding order' you mean the order set in the Advanced Settings of the Network Connections of the Control Panel, then the most important one is to make sure the domain network is at the top of the list.  Whichever network is at the top
    of the list is used first for auth functions.  So auth functions perform best when the proper network is placed first in the binding order.  After that, I don't know that it makes much difference at all.  (If it does, I'm sure my statement will
    start a lively discussion. <grin>)
    . : | : . : | : . tim

  • Using NIC Teaming and a virtual switch for Windows Server 2012 host networking and Hyper-V.

    Using NIC Teaming and a virtual switch for Windows Server 2012 host networking!
    http://www.youtube.com/watch?v=8mOuoIWzmdE
    Hi thanks for reading. Now I may well have my terminology incorrect here so I will try to explain  as best I can and apologies from the start.
    It’s a bit of both Hyper-v and Server 2012R2. 
    I am setting up a lab with Server 2012 R2. I have several physical network cards that I have teamed called “HostSwitchTeam” from those I have made several Virtual Network Adaptors such as below
    examples.
    New-VMSwitch "MgmtSwitch" -MinimumBandwidthMode weight -NetAdaptername "HostSwitchTeam" -AllowManagement $false
    Add-VMNetworkAdapter -ManagementOS -Name "Vswitch" -SwitchName "MgmtSwitch"
    Add-VMNetworkAdapter -ManagementOS -Name "Cluster" -SwitchName "MgmtSwitch"
    When I install Hyper-V and it comes to adding a virtual switch during installation it only shows the individual physical network cards and the
    HostSwitchTeam for selection.  When installed it shows the Microsoft Network Multiplexor Driver as the only option. 
    Is this correct or how does one use the Vswitch made above and incorporate into the Hyper-V so a weight can be put against it.
    Still trying to get my head around Vswitches,VMNetworkadapters etc so somewhat confused as to the way forward at this time so I may have missed the plot altogether!
    Any help would be much appreciated.
    Paul
    Paul Edwards

    Hi P.J.E,
    >>I have teams so a bit confused as to the adapter bindings and if the teams need to be added or just the vEthernet Nics?.
    Nic 1,2 
    HostVMSwitchTeam
    Nic 3,4,5
             HostMgmtSwitchTeam
    >>The adapter Binding settings are:
    HostMgmtSwitchTeam
    V-Curric
    Nic 3
    Nic 4
    Nic 5
    V-Livemigration
    HostVMSwitch
    Nic 1
    Nic 2
    V-iSCSI
    V-HeartBeat
    Based on my understanding of the description , "HostMgmtSwitchTeam and
    HostVMSwitch " are teamed NIC .
    You can think of them as two physical NICs (do not use NIC 1,2,3,4,5 any more , there are just two NICs "HostMgmtSwitchTeam and
    HostVMSwitch").
    V-Curric,
    V-Livemigration , V-iSCSI ,
    V-HeartBeat are just VNICs of host  (you can change their name then check if the virtual switch name will be changed )
    Best Regards
    Elton Ji
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Hyper-V, NIC Teaming and 2 hosts getting in the way of each other

    Hey TechNet,
    After my initial build of 2 Hyper-V Core server which took me a bit of time without a domain, I started building 2 more for another site. After the initial two, setting up the new ones went very fast until I ran into a very funny issue. And I am willing
    to bet it is just my luck but I am wondering if any other out there ended up with it.
    So, I build these 2 new servers, create a NIC teaming on each host, add the management OS adapter, give it an IP and I can ping the world. So I went back to my station and tried to start working on these hosts but I kept getting DCed especially from one
    of them. Reinstalled it and remade the NIC teaming config, just in case. Same issue
    So I started pinging both of the servers and I remarked that when one was pinging, the other one tended to not answer ping anymore and vice versa. After testing the firewall and the switch and even trying to put the 2 machines on different switches, did
    not help. So I thought, what the heck, let's just remove all the network config from both machine, reboot, and redo the network config. Since then no issue.
    I only forgot to do one thing before removing the network configuration, I forgot to check if the MAC address on the Management OS adapters were the same. Even if it is a small chance, it can still happen (1 in 256^4 i'd say).
    So to get to my question, am I that unlucky or might it have been something else ?
    Enjoy your weekends

    I raised this bug long ago (one year ago in fact) and it still happens today.
    If you create a virtual switch, then add a management vNIC to it - there are times when you will get two hosts with the same MAC on the vNIC that was added for management.
    I have seen this in my lab (and I can reproduce it at will).
    Modify the entire Hyper-V MAC address pool.  Or else you will have the same issue with VMs.  This is the only workaround.
    But yes, it is a very confusing issue.
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

  • NIC teaming and direct access in windows 2012 server core

    Hello All,
    I have installed windows 2012 r2 server core and i want to implement direct access with nic teaming enabled.
    Has anyone tried this kind of setup? Were they successful in it? Moreover can we configure Direct access when we have NIC teaming configured?
    -Ashish

    Hi There - NIC teaming in both core and gui is a standard feature and there is no reason (and I have used it successfully) why you cannot do so. As always make sure you look at TCP Offload as per UAG / TMG Days to ensure best performance and also Network
    Card Binding Order.
    The link for details is here -
    http://technet.microsoft.com/en-us/library/hh831648.aspx
    Kr
    John Davies

  • NIC teaming and Hyper-V switch recommendations in a cluster

    HI,
    We’ve recently purchased four HP Gen 8 servers with a total of ten NICS to be used in a Hyper-V 2012 R2 Cluster
    These will be connecting to ISCSI storage so I’ll use two of the NICs for the ISCSI storage connection.
    I’m then deciding between to options.
    1. Create one NIC team, one Extensible switch and create VNics for Management, Live Migration and CSV\Cluster - QOS to manage all this traffic. Then connect my VMs to the same switch.
    2. Create two NIC teams, four adapters in each.  Use one team just for Management, Live Migration and CSV\Cluster VNics - QOS to manage all this traffic. 
    Then the other team will be dedicated just for my VMs.
    Is there any benefit to isolating the VMs on their own switch?
    Would having two teams allow more flexibility with the teaming 
    configurations I could use, such as using Switch Independent\Hyper-V Port mode for the VM team? (I do need to read up on the teaming modes a little more)
    Thanks,

    I’m not teaming the ISCSI adapters.  These would be configured with MPIO. 
    What I want to know,
    Create one NIC team, one Extensible switch and create VNics for Management, Live Migration and CSV\Cluster - QOS to manage all this traffic. Then connect
    my VMs to the same switch.
    http://blogs.technet.com/b/cedward/archive/2014/02/22/hyper-v-2012-r2-network-architectures-series-part-3-of-7-converged-networks-managed-by-scvmm-and-powershell.aspx
    What are the disadvantages to having this configuration? 
    Should RSS be disabled on the NICs in this configuration with DVMQ left enabled? 
    After reading through this post, I think I’ll need to do this. 
    However, I’d like to understand this a little more.
    I have the option of adding an additional two 10GB NICS. 
    This would mean I could create another team and Hyper-V switch on top and then dedicate this to my VMs leaving the other team for CSV\Management and Live Migration.
     How does this option affect the use of RSS and DVMQ?

  • Using script to automatically arrange timeline and sceneline workspaces.

    This is a simple demonstration of using VB Script to adjust panels in PE3.
    In PE3, when you adjust the height of the timeline, the height of the sceneline is also adjusted the same amount, and vice versa. You could use script to automatically adjust the height of the sceneline or the timeline whenever you switch respective modes. The script below does that.
    This is for those who are familiar with script writing and the Windows Script Host. The vb script below includes properties and methods from the AutoItX library (free download).
    Option Explicit
    Dim oAutoit, strWinText, strLastTime, lngX, lngY
    Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
    oAutoit.WinWaitActive "Adobe Premiere Elements -"
    strLastTime = "start"
    Do
    ' Quit the script if mousepointer put in upper left corner (0,0).
    lngX = oAutoIt.MouseGetPosX
    lngY = oAutoIt.MouseGetPosY
    if lngX = 0 and lngY = 0 then
    set oAutoIt = nothing
    Wscript.Echo "Your script has ended."
    Wscript.Quit
    end if
    ' Read the text of the window so we can determine the workspace setup.
    strWinText = oAutoIt.WinGetText("Adobe Premiere Elements -")
    ' If DVD Menu tab selected, then don't do anything, otherwise
    ' check if in Sceneline or Timeline mode.
    if instr(strWinText, "DVD Menu") = 0 then
    if instr(strWinText,"EditTimeControl") <> 0 then
    if strLastTime <> "timeline" then
    ' Reset the Edit Workspace and then adjust the timeline panel height
    oAutoit.Send "{alt}wke"
    oAutoit.Sleep 250
    oAutoit.MouseMove 1078, 646
    oAutoit.MouseDown "left"
    oAutoit.MouseMove 1078,400
    oAutoit.MouseUp "left"
    strLastTime = "timeline"
    end if
    else
    if strLastTime <> "sceneline" then
    ' Reset the Edit Workspace and then adjust the sceneline panel height.
    oAutoit.Send "{alt}wke"
    oAutoit.Sleep 250
    oAutoit.MouseMove 1078, 646
    oAutoit.MouseDown "left"
    oAutoit.MouseMove 1078,762
    oAutoit.MouseUp "left"
    strLastTime = "sceneline"
    end if
    end if
    end if
    WScript.Sleep 2000
    loop
    The script might work as-is if your screen is set for 1280 x 1024 and the Premiere Elements 3 window is maximized. Save the script in a text file with a .VBS extension, and then run it. Afterwards click on the Sceneline or Timeline buttons in PE3. It may take up to 2 seconds before the mouse starts moving on it's own. The screen coordinates were ascertained using the AutoIt Info tool.

    You shouldn't make assumptions about what the names of the volumes are - both the Finder and System Events have terminology to determine if a disk is the startup volume (or a local volume, for that matter), for example:
    tell application "System Events"
      repeat with someDisk in (get disks whose startup is false and local volume is true)
        set someDisk to POSIX path of someDisk
        do shell script "diskutil umount " & quoted form of someDisk & " &> /dev/null &"
      end repeat
    end tell
    Note that if you are unmounting a disk from a standard account you will be prompted for administrator authentication.

  • Nic teaming and hyper-v switches

    I come from the ESX world but I am slowly falling in love with the simplicity of Hyper-v. I have a stack of dell c2100's I have been experimenting with. each have 2 1gb connections  teamed to a cisco switch. when testing bandwidth with a file copy I
    get around 240MBps. however if I add a hyper-v switch I max out at 90Mbps. worse than no teaming at all (112Mbps). 
    team is with integrated broadcom nics, LACP and I can confirm I get full bandwidth between 2 2012 r2 machines until adding a hyper-v switch. removing the switch lets me transfer at full bandwidth but then I cant use Hyper-v guests.
    my goal will eventually be to add dual port 10gb cards to 5 of the C2100's and run them in a cluster to host all my VM's in HA. I don't want to waist my money on the switch and nics until I can get what i have working correctly.
    HDD speed is also not the issue as each has 12 3tb WD re4 drives with 2 Intel 250GB ssd as cache. they easily hold 3000MBps sustained.

    http://itproctology.blogspot.com/2008/05/hyper-v-tcpoffloading-poor-network.html
    http://itproctology.blogspot.com/2011/03/tcp-checksum-offload-is-not-equal-to.html
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

  • Configure static ip address through time capsule for Filemaker Pro

    I am trying to setup a static IP Address for Filemaker Pro Instant Web Publishing.
    My current configuration is that I have a Netgear CG3100D modem/router set up to be a modem only.  NAT Mode is Disabled (Bridge Mode).  This is then connected to my Apple TimeCapsule.
    What I am now trying to do is to configure my Windows 7 PC to have a static IP address so that remote devices can access my filemaker pro database.
    I have downloaded (and configured?) a tool called no-ip DUC v3.04 that I thought would help solve my connection issues, but I think that I still have a problem with how to open a port number.
    When i open my browser and make a connection on my network with the ip address:port number specified through Filemaker I can get a connection.  However I can not get a connection remotely.
    I know I haven't provided a great deal of information here, but I am happy to provide more, once I konw what information is required.
    Any assistance or advice with this would be really appreciated.
    Thanks

    I'm not too familiar with FileMaker Pro, but if you like to give static IP addresses to anything you would have to use DHCP Reservations using Airport Utility.
    Open Airport Utility, select the Time Capsule device, click Manual Setup, navigate the Internet icon, then the DHCP tab, you'll see DHCP Reservations towards the bottom.

  • NIC Teaming and 3750 stack

    Has anyone succesfully connected a windows machine to two different switches in the 3750 stack

    Hi
    Etherchannel is supported between switches in the same stack - so you can either build an EtherChannel type team, or a simple fault-tolerant team no problem.
    Regards
    Aaron
    Please rate helpful posts..

  • Help creating a script to move users in and out of an OU based on a time limit

    Here's my scenario: we currently have OUs based on the locations of our facilities, we also have a sub-OU(?) underneath it for users that need a group policy applied to them where whitelist applications allowed to run. From time to time we have need to pull
    users out of that sub-OU for a short period of time to let them run applications they normally wouldn't be able to and won't need to run long term. Sometimes we also forget to add these people back into that policy controlled sub-OU because we get busy do
    other things. Server is 2008 R2.
    Here's what I'm looking for: A script that prompts for the users name, pulls that user out of the sub-OU, puts them in the main OU but only for 24 hours. After that time limit is up, a script/command runs that puts the user back in the policy controlled
    sub-OU. I'm thinking a PS script would be the best way to do this.
    Research: Looking at these posts here and here I'm
    thinking I should be able to Frankenstein something together but I have very limited PS scripting experience.
    Can anyone help me create this?

    You've probably figured this out, but we're not typically in the business of writing complete solutions for people. With that said, there are projects I find particularly interesting, such as this one, where I am willing to help get someone started if they
    are willing to take the time to work through the examples and learn from them.
    You have two requests - one is a script that prompts for a user it then moves to a different  location in Active Directory. The second request is a way to move them back without manual interaction. This will require an automated task (scheduled task)
    that will run at select times during a day.
    Here's the first script (1/2): The first two lines set two different variables. The first line sets the $OUPath variable to the SubOU. The second line prompts for a user and, once a user is entered, sets that user to the $User variable. It then runs the
    first try-catch, attempting to replace the $User variable with the data returned from the Get-ADUser cmdlet. Notice the use of the -Properties parameter. By default the modified date and the extensionAttributes are not returned. We will be using the modified
    date so we can be certain that 24 hours passes before we move them back (see part 2/2). Including extensionAttribute13 will ensure we only move users out of the OU if they were moved in by the script. Note: The modified date on a user in AD is changed when
    it is moved from one OU to another. If the user cannot be located in the first try-catch it will say it cannot locate the user in Active Directory. If it can locate it, it will set the $User variable, as described so far, and then move on.
    In the second (or, nested) try-catch we split the user's DistingusihedName at the first comma so that we have two parts. We use the second part (that doesn't include their CN) and see if that matches the $OUPath variable. If it does match then that user
    has already been moved. If it doesn't match then we 1. Move the user, 2. Replace extensionAttribute13 with the string 'MovedUser,' and 3. Output that the user has been moved.
    $OUPath = 'OU=SubOU,OU=MainOU,DC=mydomain,DC=com'
    $User = Read-Host -Prompt 'Enter SamAccountName'
    try {
    $User = Get-ADUser -Identity $User -Properties Modified,extensionAttribute13
    try {
    If ($User.DistinguishedName.Split(',',2) -eq $OUPath) {
    Write-Output -Verbose 'User already moved.'
    } Else {
    Move-ADObject -Identity $User.DistinguishedName -TargetPath $OUPath
    Set-ADUser -Identity $User.SamAccountName -Replace @{extensionAttribute13='MovedUser'}
    Write-Output "'$($User.SamAccountName)' has been moved."
    catch {
    Write-Output "'$($User.SamAccountName)' cannot be moved."
    catch {
    Write-Output -Verbose "Unable to locate '$User' in Active Directory."
    The second script (2/2): Here we also set a couple variables - one is the SubOU's DistinguishedName where we want to return the user and the other is the all of the users from the MainOU. Foreach user in $Users we check if their extensionAttribute13 is set
    to 'MovedUser' and if their modified date is greater than or equal (-ge) to 24 hours. If it is, the script will move the user, clear extensionAttribute13, and let us know the user was moved. If for some reason your $OUPath variable is wrong, the script will
    run the catch portion of the only try-catch we used in this script. Again, you'll have to schedule Task Scheduler to run this script. Good luck!
    $OUPath = 'OU=MainOU,DC=mydomain,DC=com'
    $Users = Get-ADUser -Filter * -SearchBase $OUPath -Properties Modified,extensionAttribute13
    Foreach ($User in $Users) {
    $TimeSince = New-TimeSpan -Start $User.Modified -End (Get-Date)
    If ($User.extensionAttribute13 -eq 'MovedUser' -and $TimeSince.Hours -ge 24) {
    try {
    Move-ADObject -Identity $User.DistinguishedName -TargetPath $OUPath
    Set-ADUser -Identity $User.SamAccountName -Clear extensionAttribute13
    Write-Output "$($User.SamAccountName) has been moved."
    catch {
    Write-Output "$($User.SamAccountName) cannot be moved."
    } Else {
    Write-Output 'No Users to move.'
    If you decide to use this, be sure to change the paths you use for the $OUPath variables. Also, if you're using this with PowerShell 2.0, you will need to use the Import-Module cmdlet to import the ActiveDirectory module. In versions above 2.0 it will be
    imported automatically if you try to use an AD cmdlet.
    Edit: Typo - Get-ADUser property

  • How do I read a txt file and keep only IP addresses based on the first 2 or 3 octets of the IP?

    Hello,
    I have a text file and each line contains random text followed by an IP address as follows.
    some text....172.30.25.30
    some text.....172.30.85.10
    some text..172.30.25.35
    some text.......172.30.85.11
    some text....172.30.15.1
    some text...172.30.15.2
    some text.......172.10.1.1
    some text...172.20.4.2
    some text..172.10.1.2
    some text.....172.20.5.1
    I'd like to create an output file which has only one entry for each unique entry in the file where either the first 2 or 3 octets are unique as follows:
    Output File
    172.30.25
    172.30.85
    172.30.15
    172.10.1
    172.20
    Any suggestions are appreciated!
    Thanks for your help! SdeDot

    Thanks mjolinor.  Works great!
    Two questions.
    1. Could you plz suggest how this could be modified so this code would read the file in or accept it from the pipeline instead of wrapping the (@' around the data?
    2. Could you plz briefly describe some of the details of the code so I can further research and understand.
    Thanks for your help.
    Thanks for your help! SdeDot
    1. It already reads in the file.  The (@' .. '@) bits are just there to create a file using your test data to demonstrate that it works.
    2.  Not user what kind of "details" you want.  There really isn't much there, and get-help on the cmdlets used should provide information on what's going on with them in that script.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • VMQ issues with NIC Teaming

    Hi All
    Apologies if this is a long one but I thought the more information I can provide the better.
    We have recently designed and built a new Hyper-V environment for a client, utilising Windows Server R2 / System Centre 2012 R2 however since putting it into production, we are now seeing problems with Virtual Machine Queues. These manifest themselves as
    either very high latency inside virtual machines (we’re talking 200 – 400 mSec round trip times), packet loss or complete connectivity loss for VMs. Not all VMs are affected however the problem does manifest itself on all hosts. I am aware of these issues
    having cropped up in the past with Broadcom NICs.
    I'll give you a little bit of background into the problem...
    Frist, the environment is based entirely on Dell hardware (Equallogic Storage, PowerConnect Switching and PE R720 VM Hosts). this environment was based on Server 2012 and a decision was taken to bring this up to speed to R2. This was due to a number
    of quite compelling reasons, mainly surrounding reliability. The core virtualisation infrastructure consists of four VM hosts in a Hyper-V Cluster.
    Prior to the redesign, each VM host had 12 NICs installed:
    Quad port on-board Broadcom 5720 daughter card: Two NICs assigned to a host management team whilst the other two NICs in the same adapter formed a Live Migration / Cluster heartbeat team, to which a VM switch was connected with two vNICs exposed to the
    management OS. Latest drivers and firmware installed. The Converged Fabric team here was configured in LACP Address Hash (Min Queues mode), each NIC having the same two processor cores assigned. The management team is identically configured.
    Two additional Intel i350 quad port NICs: 4 NICs teamed for the production VM Switch uplink and 4 for iSCSI MPIO. Latest drivers and firmware. The VM Switch team spans both physical NICs to provide some level of NIC level fault tolerance, whilst the remaining
    4 NICs for ISCSI MPIO are also balanced across the two NICs for the same reasons.
    The initial driver for upgrading was that we were once again seeing issues with VMQ in the old design with the converged fabric design. The two vNics in the management OS for each of these networks were tagged to specific VLANs (that were obviously accessible
    to the same designated NICs in each of the VM hosts).
    In this setup, a similar issue was being experienced to our present issue. Once again, the Converged Fabric vNICs in the Host OS would on occasion, either lose connectivity or exhibit very high round trip times and packet loss. This seemed to correlate with
    a significant increase in bandwidth through the converged fabric, such as when initiating a Live Migration and would then affect both vNICS connectivity. This would cause packet loss / connectivity loss for both the Live Migration and Cluster Heartbeat vNICs
    which in turn would trigger all sorts of horrid goings on in the cluster. If we disabled VMQ on the physical adapters and the team multiplex adapter, the problem went away. Obviously disabling VMQ is something that we really don’t want to resort to.
    So…. The decision to refresh the environment with 2012 R2 across the board (which was also driven by other factors and not just this issue alone) was accelerated.
    In the new environment, we replaced the Quad Port Broadcom 5720 Daughter Cards in the hosts with new Intel i350 QP Daughter cards to keep the NICs identical across the board. The Cluster heartbeat / Live Migration networks now use an SMB Multichannel configuration,
    utilising the same two NICs as in the old design in two isolated untagged port VLANs. This part of the re-design is now working very well (Live Migrations now complete much faster I hasten to add!!)
    However…. The same VMQ issues that we witnessed previously have now arisen on the production VM Switch which is used to uplink the virtual machines on each host to the outside world.
    The Production VM Switch is configured as follows:
    Same configuration as the original infrastructure: 4 Intel 1GbE i350 NICs, two of which are in one physical quad port NIC, whilst the other two are in an identical NIC, directly below it. The remaining 2 ports from each card function as iSCSI MPIO
    interfaces to the SAN. We did this to try and achieve NIC level fault tolerance. The latest Firmware and Drivers have been installed for all hardware (including the NICs) fresh from the latest Dell Server Updates DVD (V14.10).
    In each host, the above 4 VM Switch NICs are formed into a Switch independent, Dynamic team (Sum of Queues mode), each physical NIC has
    RSS disabled and VMQ enabled and the Team Multiplex adapter also has RSS disabled an VMQ enabled. Secondly, each NIC is configured to use a single processor core for VMQ. As this is a Sum of Queues team, cores do not overlap
    and as the host processors have Hyper Threading enabled, only cores (not logical execution units) are assigned to RSS or VMQ. The configuration of the VM Switch NICs looks as follows when running Get-NetAdapterVMQ on the hosts:
    Name                           InterfaceDescription             
    Enabled BaseVmqProcessor MaxProcessors NumberOfReceive
    Queues
    VM_SWITCH_ETH01                Intel(R) Gigabit 4P I350-t A...#8 True    0:10             1            
    7
    VM_SWITCH_ETH03                Intel(R) Gigabit 4P I350-t A...#7 True    0:14             1            
    7
    VM_SWITCH_ETH02                Intel(R) Gigabit 4P I350-t Ada... True    0:12             1            
    7
    VM_SWITCH_ETH04                Intel(R) Gigabit 4P I350-t A...#2 True    0:16             1            
    7
    Production VM Switch           Microsoft Network Adapter Mult... True    0:0                           
    28
    Load is hardly an issue on these NICs and a single core seems to have sufficed in the old design, so this was carried forward into the new.
    The loss of connectivity / high latency (200 – 400 mSec as before) only seems to arise when a VM is moved via Live Migration from host to host. If I setup a constant ping to a test candidate VM and move it to another host, I get about 5 dropped pings
    at the point where the remaining memory pages / CPU state are transferred, followed by an dramatic increase in latency once the VM is up and running on the destination host. It seems as though the destination host is struggling to allocate the VM NIC to a
    queue. I can then move the VM back and forth between hosts and the problem may or may not occur again. It is very intermittent. There is always a lengthy pause in VM network connectivity during the live migration process however, longer than I have seen in
    the past (usually only a ping or two are lost, however we are now seeing 5 or more before VM Nework connectivity is restored on the destination host, this being enough to cause a disruption to the workload).
    If we disable VMQ entirely on the VM NICs and VM Switch Team Multiplex adapter on one of the hosts as a test, things behave as expected. A migration completes within the time of a standard TCP timeout.
    VMQ looks to be working, as if I run Get-NetAdapterVMQQueue on one of the hosts, I can see that Queues are being allocated to VM NICs accordingly. I can also see that VM NICs are appearing in Hyper-V manager with “VMQ Active”.
    It goes without saying that we really don’t want to disable VMQ, however given the nature of our clients business, we really cannot afford for these issues to crop up. If I can’t find a resolution here, I will be left with no choice as ironically, we see
    less issues with VMQ disabled compared to it being enabled.
    I hope this is enough information to go on and if you need any more, please do let me know. Any help here would be most appreciated.
    I have gone over the configuration again and again and everything appears to have been configured correctly, however I am struggling with this one.
    Many thanks
    Matt

    Hi Gleb
    I can't seem to attach any images / links until my account has been verified.
    There are a couple of entries in the ndisplatform/Operational log.
    Event ID 7- Querying for OID 4194369794 on TeamNic {C67CA7BE-0B53-4C93-86C4-1716808B2C96} failed. OidBuffer is  failed.  Status = -1073676266
    And
    Event ID 6 - Forwarding of OID 66083 from TeamNic {C67CA7BE-0B53-4C93-86C4-1716808B2C96} due to Member NDISIMPLATFORM\Parameters\Adapters\{A5FDE445-483E-45BB-A3F9-D46DDB0D1749} failed.  Status = -1073741670
    And
    Forwarding of OID 66083 from TeamNic {C67CA7BE-0B53-4C93-86C4-1716808B2C96} due to Member NDISIMPLATFORM\Parameters\Adapters\{207AA8D0-77B3-4129-9301-08D7DBF8540E} failed.  Status = -1073741670
    It would appear as though the two GUIDS in the second and third events correlate with two of the NICs in the VM Switch team (the affected team).
    Under MSLBFO Provider/Operational, there are also quite a few of the following errors:
    Event ID 8 - Failing NBL send on TeamNic 0xffffe00129b79010
    How can I find out what tNIC correlates with "0xffffe00129b79010"
    Without the use of the nice little table that I put together (that I can't upload), the NICs and Teams are configured as follows:
    Production VM Switch Team (x4 Interfaces) - Intel i350 Quad Port NICs. As above, the team itself is balanced across physical cards (two ports from each card). External SCVMM Logical Switch is uplinked to this team. Serves
    as the main VM Switch for all Production Virtual machines. Team Mode is Switch Independent / Dynamic (Sum of Queues). RSS is disabled on all of the physical NICs in this team as well as the Multiplex adapter itself. VMQ configuration is as follows:
    Interface Name          -      BaseVMQProc          -        MaxProcs         
    -      VMQ / RSS
    VM_SWITCH_ETH01                  10                             
         1                           VMQ
    VM_SWITCH_ETH02                  12                              
        1                           VMQ
    VM_SWITCH_ETH03                  14                               
       1                           VMQ
    VM_SWITCH_ETH04                  16                              
        1                           VMQ
    SMB Fabric (x2 Interfaces) - Intel i350 Quad Port on-board daughter card. As above, these two NICs are in separate, VLAN isolated subnets that provide SMB Multichannel transport for Live Migration traffic and CSV Redirect / Cluster
    Heartbeat data. These NICs are not teamed. VMQ is disabled on both of these NICs. Here is the RSS configuration for these interfaces that we have implemented:
    Interface Name          -      BaseVMQProc          -        MaxProcs       
      -      VMQ / RSS
    SMB_FABRIC_ETH01                18                                   2                           
    RSS
    SMB_FABRIC_ETH02                18                                   2                           
    RSS
    ISCSI SAN (x4 Interfaces) - Intel i350 Quad Port NICs. Once again, no teaming is required here as these serve as our ISCSI SAN interfaces (MPIO enabled) to the hosts. These four interfaces are balanced across two physical cards as per
    the VM Switch team above. No VMQ on these NICS, however RSS is enabled as follows:
    Interface Name          -      BaseVMQProc         -         MaxProcs      
       -        VMQ / RSS
    ISCSI_SAN_ETH01                    2                                    2                           
    RSS
    ISCSI_SAN_ETH02                    6                                    2                           
    RSS
    ISCSI_SAN_ETH03                    2                                   
    2                            RSS
    ISCSI_SAN_ETH04                    6                                   
    2                            RSS
    Management Team (x2 Interfaces) - The second two interfaces of the Intel i350 Quad Port on-board daughter card. Serves as the Management uplink to the host. As there are some management workloads hosted in this
    cluster, a VM Switch is connected to this team, hence a vNIC is exposed to the Host OS in order to manage the Parent Partition. Teaming mode is Switch Independent / Address Hash (Min Queues). As there is a VM Switch connected to this team, the NICs
    are configured for VMQ, thus RSS has been disabled:
    Interface Name        -         BaseVMQProc        -          MaxProcs       
    -         VMQ / RSS
    MAN_SWITCH_ETH01                 22                                  1                          
    VMQ
    MAN_SWITCH_ETH02                 22                                  1                           VMQ
    We are limited as to the number of physical cores that we can allocate to VMQ and RSS so where possible, we have tried balance NICs over all available cores where practical.
    Hope this helps.
    Any more info required, please ask.
    Kind Regards
    Matt

Maybe you are looking for