Hi all,
I have to create ~40 VMs, all based on a template, so I'm giving it a go via PowerCLI. I've had moderate success with my script, however, SOMETIMES, I get the error:
The operation for the entity VirtualMachine-vm-449 failed with the following message: "fault.NicSettingMismatch.summary"
I'm not trying to add or remove any more NICs, and the template only has one NIC. This is on vCenter Server 5, using ESXi 5 hosts. Here's my script:
Add-PSSnapin VMware.VimAutomation.Core
$creds = Get-Credential
connect-viserver vcenterserver -Credential $creds
$dns1 = "1.1.1.2"
$dns2 = "1.1.1.3"
$wins1 = "1.1.1.4"
$wins2 = "1.1.1.5"
$dnssuffix = "test.domain.org"
$servers =Import-Csv "c:\scripts\buildboxes.csv"
foreach($s in $servers){
New-OSCustomizationSpec -OSType Windows `
-fullname "Administrator" `
-orgname "Organization" `
-Name $s.name `
-ChangeSid `
-AdminPassword "Password01" `
-TimeZone "035" `
-Domain $dnssuffix `
-DomainCredentials $creds `
-autologoncount 3 `
-namingscheme Fixed `
-namingprefix $s.name
New-OSCustomizationNicMapping -OSCustomizationSpec $s.name `
-Position 1 `
-IpMode UseStaticIP `
-IPAddress $s.IPAddress `
-SubnetMask 255.255.255.0 `
-DefaultGateway 1.1.2.1`
-Dns $dns1,$dns2 `
-Wins $wins1,$wins2
new-vm -vmhost $s.vmhost -name $s.vmname -template buildbox -OSCustomizationSpec $s.name
Remove-OSCustomizationSpec $s.Name -Confirm:$false
get-vm $s.vmname | start-vm -confirm:$false -RunAsync
}