0 Replies Latest reply on Oct 22, 2015 1:34 PM by Yanick Girouard

    Automating vmware network adapter type change using scripting and BladeLogic

    Yanick Girouard

      We have several dozens of Windows virtual machines in a VMware ESXi 5.5 environment that were recently migrated from older versions and still use old network adapter types (such as PCNET32, VMXNET, VMXNET2, etc...) and we need a way to change all of them to VMXNet3 without requiring manual interventions (as much as possible).


      We already use powercli for many tasks, so I'm looking on that side already. I found a simple trick to chang ethe adapter type without having to remove/add adapters in the VM using the vSphere GUI, which is this powercli command:


      Get-VM -Name "VM" | Get-NetworkAdapter | set-networkadapter -type vmxnet3 -confirm:$false


      Then we need to initiate a guest os shutdown from VMware and restart it. The problem is that doing so, the server detects new adapters, and even though they still keep the same MAC address, the driver changes so they appear as new cards and the network configuration is lost.


      We need to remove the old cards from the hidden network devices in the device manager and then manually rename and reset the config of the new adapters manually using a local admin account, using the vSphere Console. I have tried the VmUpgradeHelper.bat trick that is documented in the VMware kb, but because the adapter actually changes, it doesn't work at all.


      Other tricks I have found on Google suggest using the "netsh interfaces dump" command to dump and restore the configuration, but that won't work either because the name of the new interfaces that show up is different than the previous ones (we name network interfaces in function of their vlan, i.e. vlan1234), and I also first need to delete the old hidden adapter from the device manager before I can reuse the same name on the new interfaces.


      Simply put, this is what I would need:


      1. Backup the network configuration (as many settings as possible) per MAC address

      2. Run another script using the backed up data to:

           a) Delete the old hidden adapters
           b) for each new adapter, find the corresponding config based on the MAN address that didn't change
           c) rename the devices, and restore their configuration to restore connectivity.

      I can use the powercli Invoke-vmscript if needed to call a script locally from powercli since BSA won't be able to talk to the RSCD agent anymore once the server is restarted with the new adapter types.


      Would anyone already have something that can do this or could share their recipe to automate it ? I'll still be looking around until then, but all I found so far was to use extensive powershell scripting to completely backup the network settings of each adapter and re-set everything after using the set- command equivalents, but it's quite tedious and complex (i.e. Using PowerShell for NIC Configuration Tasks - Server and Cloud Partner and Customer Solutions Team Blog - Site Home - T…). If anyone has something easier I'm all eyes !