VMware Cloud Community
jesse_gardner
Enthusiast
Enthusiast

New-VM assigns an unexpected default virtual NIC when run against specific clusters

This is an odd one for me.  Part of our automation expects that the New-VM cmdlet results in a VM without a NIC, which we then configure later.  At some point in the last week or two, some of these started showing up with a NIC at that point, which broke some things.  As the usual story goes, I can't identify a vCenter or host change that corresponds with this.  We upgraded vCenter and hosts from 5.1 to 5.5 about a month ago, but ran for at least 3 weeks without having or noticing this symptom.

So, here's what I've narrowed down so far.  We have about 26 clusters and 120 hosts.  This symptom only happens on two of the clusters.  When sending a vmhost object on the pipeline to new-vm, the resultant VM never has a NIC (expected, good).  However, when sending a cluster object on the pipeline to new-vm, two of our 26 clusters result in a VM with a NIC (problematic for us).

Sample script that shows this behavior (with our cluster/host names redacted):

$cluster = get-cluster <clustername>

#cluster itself

write-host "Cluster $cluster"

$vm = $cluster | new-vm -name "TestVM" -GuestId "windows8Server64Guest"

$numnics = $vm | Get-NetworkAdapter | measure | select -ExpandProperty count

write-host "`tNumber of NICs: $numnics"

$vm | Remove-VM -confirm:$false -DeletePermanently

#hosts individually

$cluster | get-vmhost | ?{$_.connectionstate -eq "Connected"} | sort name | %{

    write-host "Host $_"

    $vm = $_ | new-vm -name "TestVM" -GuestId "windows8Server64Guest"

    $numnics = $vm | Get-NetworkAdapter | measure | select -ExpandProperty count

    write-host "`tNumber of NICs: $numnics"

    $vm | Remove-VM -confirm:$false -DeletePermanently

}

Results:

Cluster <clustername>

  Number of NICs: 1

Host <host1>

  Number of NICs: 0

Host <host2>

  Number of NICs: 0

Host <host3>

  Number of NICs: 0

Host <host4>

  Number of NICs: 0

Host <host5>

  Number of NICs: 0

Some info about the NIC that's added.  Note, the network "VM  Network" doesn't even exist on these hosts!  We use dVS.

> $vm | Get-NetworkAdapter | Format-List *

MacAddress       : <mac>

WakeOnLanEnabled : True

NetworkName      : VM Network

Type             : e1000e

ParentId         : VirtualMachine-vm-90490

Parent           : <vmname>

ConnectionState  : NotConnected, NoGuestControl, StartConnected

ExtensionData    : VMware.Vim.VirtualE1000e

Id               : VirtualMachine-vm-90490/4000

Name             : Network adapter 1

Client           : VMware.VimAutomation.ViCore.Impl.V1.VimClient

And for what it's worth, I'm on recent or latest releases of PowerCLI (5.5 R2 P1 build 1931983), vCenter (5.5 U1a build 1750787), ESXi (5.5 build 1892794).

Any ideas?  Thanks!

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Could this be due to the default compatibility you have configured for VM Creation ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jesse_gardner
Enthusiast
Enthusiast

Very interesting LucD, I wasn't aware of that setting.  However, everywhere I click (affected and unaffected datacenters, clusters, and hosts), I find the default "Use datacenter/cluster setting and host version"

Reply
0 Kudos
jesse_gardner
Enthusiast
Enthusiast

A bit of a revelation on what is still odd behavior:  If a cluster of fully configured hosts connected to dVS has one host in maintenance mode (still configuring before move to production), and that maintenance host has a local/standard VM portgroup (as is default but most people would remove), this behavior will occur.

Piping the cluster object to New-VM cmdlet will add a NIC connected to that standard portgroup, even though it will be invalid on the non-maintenance-mode host it will run on.  Simply removing the standard VM portgroup from the maintenance-mode host and New-VM creates a VM without a NIC.

Interestingly, the webclient GUI wizard does the same thing.vmnic.png

Reply
0 Kudos
LucD
Leadership
Leadership

Interesting, I have no knowledge of this being documented anywhere.

Looks more like a glitch to me :smileymischief:


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos