VMware Cloud Community
RaulC
Contributor
Contributor

NIC Disconnects when creating a Windows VM

I am currently in the process of writing a script that will create a Windows or Linux VM depending on what the user inputs into the scripts

I was able to get the Linux side working great, but the Windows one is causing a few weird issues. It creates the VM, and assigns the NIC the correct IP address, but for some weird reason it Disconnects the NIC, so anytime I create a windows VM I have to go through the process of Editting the setting and onlining the NIC. Is there some weird reason this would be happening?

I've also verified that the NIC is in fact online and connected on power on for the Template that I'm using so that isn't the issue

Here is a snippet of the code:

If($OSType -eq "Windows")

{

New-OSCustomizationSpec -Name "WindowsSpec" -Type Persistent -ChangeSid -OSType Windows -OrgName "Comp 420" -Workgroup "Workgroup" -FullName "Administrator" -AdminPassword "Password"

Get-OSCustomizationSpec -Name "WindowsSpec" | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $IpAddress -SubnetMask $SubnetMask -Dns $DNS -DefaultGateway $DefaultGateway

New-VM -Name $VMName -Template $Template -VMHost $VMHost -OSCustomizationSpec "WindowsSpec"

}

For some odd reason it also prompts me to reset the Admin password whenever I try to logon to the new VM even though I am specifying the password with the -AdminPassword parameter

Reply
0 Kudos
1 Reply
Madmax01
Expert
Expert

Hello Smiley Wink,

i'am not 100% quit sure about issue below, but maybe Info helps. i just played around with cloning scripts longer time ago with

- csv as a Input file to have "namenew,lun,source,host,ipaddress,subnet,gateway,pdns,sdns,orgname,newsid,namingschema,autocount,fullname,apassword"

- fixed Customization Specifications  inside the Manager View.  So i didn't created inside script

i remember had same problem with the Password,  i locked in my old Code

could you try out for the pass:  maybe that helps

"

$adminpass = "Password"

$spec.ExtensionData.Spec.Identity.GuiUnattended.Password.PlainText = $true

$pass = $spec.ExtensionData.Spec.Identity.GuiUnattended.Password.Value = "$Password"

New-OSCustomizationSpec -Name "WindowsSpec" -Type Persistent -ChangeSid -OSType Windows -OrgName "Comp 420" -Workgroup "Workgroup" -FullName "Administrator" -AdminPassword $pass

"

with the Nic Troubles > you have it only with windows Vm's?didn't had the problem in former days.  So as for it i maybe would have thought that you have 5.1 esxi and fixed vSwitch Ports.   with 5.5 it's dynamicly.  vmxnet3 would be good to use.

could you check out if the Template of the Windows VM is not having any issue related to the virtual HW?  could you try to manually deploy 1 VM from Windows Template? same issue?

best regards

Max

Reply
0 Kudos