Work with E1000E NICs in PowerCLI

Now that Windows 8 and Windows Server 2012 are readily available , we all want to do some exploring. But if you want to automate the creation of some test VMs for this, you are in for a surprise.

The current PowerCLI 5.1 Release 1 doesn’t accept the E1000E NIC as a Type on the New-NetworkAdapter cmdlet. Users start hitting this limitation, as can be seen on this PowerCLI Community thread. You can go for the E1000, but why settle for less if you can easily script the use of the E1000E NIC from PowerCLI?

So even though Eric “the Scoop Meister” Sloof debunked the myth that the E1000/E1000E is faster than the VmxNet3, the E1000E is the default NIC type that vSphere gives you when you create a VM for a Windows Server 2012 or Windows 8 VM. Note that the E1000 apparently uses slightly more CPU resources than the E1000E. With the function in this post you can now automate this behavior.

Update November 17th 2012: In KB2006859 it seems to say that the VMXNET3 NIC doesn’t work with Windows Server 2012 or Windows 8. And there have been several blogs (including mine) that picked up this info. But after you apply the September 2012 patch to your ESXi servers, you can also use a VMXNET3 NIC for both Windows OS. See here and here for more info.

Thanks to reader alcapapower for drawing my attention to this (see his remark in the comments below).

The Script

Annotation

Line 39-44: The function supports two parametersets, NetworkName and DistributedSwitch. The parameters NetworkName and DistributedSwitch/PortKey belong to different parametersets and can not be used together.

Line 47-91: The VirtualMachineConfigSpec parameter for the ReconfigVM_Task method is the same for each call, except for the PortKey property (if it is used). For this reason the object is created and configured in the Begin section of the function.

Line 55: Depending on the parameterset used, different properties need to be set.

Line 58: If the NetworkName is for a portgroup on a DistributedSwitch other pproperties need to be set.

Line 71-73, 95-97: A simple implementation of Object By Name

Line 76-79: If the function gets a PortKey that can not be mapped to a PortGroup, the function will exit.

Line 99: The use of an E1000E NIC requires that the VM is at least on hardware version 8.

Line 101-104: If the function is used to add an E1000E NIC on multiple VMs, and if the PortKey parameter is used, the function will automatically take the next portnumber. Make sure that there are enough free ports available to accommodate all the VMs you pass to the function.

Sample run

The function can be used in several ways.

You can call it by passing a NetworkName parameter.

And you can also use the function in a pipeline construct.

The NetworkName parameter can also point to a portgroup on a DistributedSwitch

You can specify a specific port with the PortKey parameter. Note that this parameter always needs to be used together with the DistributedSwitch parameter.

The function increments the PortKey by 1 if you call the function for more than 1 VM. Make sure there are enough free ports, starting from the port you pass in PortKey, to accommodate all the VM for which you call the function.

My dvSwitch scripting – Part 12 – Find free ports post might come in handy here :-)

Enjoy !

6 Comments

    Derek Seaman

    I wrote a blog post about how to integrate VMXNET3 and PVSCSI drivers directly into the WS2012 and Windows 8 ISOs:

    https://derek858.blogspot.com/2012/10/inject-vsphere-drivers-into-windows.html

    Works like a charm on our ESXi 821926 servers.

      LucD

      Thanks for sharing Derek, great post and very useful info.

    junkydoll

    Hi Luc, great site.

    Not wanting to be picky, but your function name seems to be missing a zero …

    Cheers

      LucD

      @Junkydoll, thanks for spotting that.
      The name has been updated.

    alpacapowered

    Great script, but I have to disagree about the statement that the vmxnet3 vNIC doesn’t work with Windows Server 2012/Windows 8 even though that KB article suggests otherwise.

    I have a couple of Windows Server 2012 VMs with vmxnet3 which are running fine on ESXi 5.0 U1 and latest patches.

    Using vmxnet3 is also explicitly supported on 5.1 and 5.0 according to the official HCL:
    https://www.vmware.com/resources/compatibility/detail.php?deviceCategory=software&testConfig=16&productid=19174&releaseid=171&supRel=171,168
    https://www.vmware.com/resources/compatibility/detail.php?deviceCategory=software&testConfig=16&productid=13500&releaseid=168&supRel=171,168

    Btw the line number annotations seem a bit off – I can only see 88 lines of code in your script.

      LucD

      @alpacapowered, thanks for the feedback.

      The inline function help lines were missing, that should be corrected now.

      I just did another test;
      I patched my server to the latest build, ESXi 5.0.0 build 821926.
      I created a VM with a vmxnet3 card and installed Windows Server 2012 on there.
      This time the VM with Windows Server 2012 comes up without a problem.
      So it looks as if there is a fix in one of the September patches for the problem that existed with VMXNET3 and Windows Server 2012. Unfortunately the patch documentation doesn’t seem to list any specifics for these new Windows OS.

      In any case, I’ll update my post with this new information.
      Then

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.