Hi guys,
the more time I spend on trouble shooting this issue the more I think it's a bug.
I have tried 2 different ways (new-vm and clonevm_task) of cloning vm's and I cannot set the default gateway on my vm's.
My script has been shortened and only shows the core part where I'm having problems. Default gateway shows up empty but only on Windows Server 2008 Enterprise x86 and x64. I tried reinstalling the OS but it makes no difference. Setting the default gateway works fine on other Windows operating systems.
I rewrote the script to actually create a customization template and it seems fine. And when I clone manually in the GUI I can make it work!
I have the exact same issue when using the clonevm_task and setting ip this way:
$vmcSpec
.Customization.NicSettingMap[0].Adapter.Ip.IpAddress = $ip
$vmcSpec
.Customization.NicSettingMap[0].Adapter.SubnetMask = $subnetmask
$vmcSpec
.Customization.NicSettingMap[0].Adapter.Gateway = $gateway
$vmcSpec
.Customization.NicSettingMap[0].Adapter.DnsServerList = $dns
My script:
$vmname = "server1" $ip = "192.168.1.2"
$subnetmask = "255.255.255.0"
$gateway = "192.168.1.1"
$dns = "192.168.0.1","192.168.0.2"
$vmtemplate = "w2k8-ent-x86"
$vmesxhost = "ESX1"
$datastore = "LUN1"
$notes = "PowerCLI cloning test"
$CustSpec = New-OSCustomizationSpec -Name $vmname `
-FullName 'Something' `
-OrgName 'Something' `
-OSType 'Windows' `
-ChangeSID `
-ProductKey "aaaaa-bbbbb-ccccc-ddddd-eeeee" `
-AutoLogonCount 1 `
-Type 'Persistent' `
-AdminPassword "secret" `
-TimeZone 105 `
-Workgroup 'workgroup' `
-LicenseMode 'PerSeat'
Get-OSCustomizationSpec $custspec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $ip -SubnetMask $subnetmask -DefaultGateway $gateway -Dns $dns
$task = New-VM -Template $vmtemplate -VMHost $vmesxhost -Name $vmname -Datastore $datastore -Description $notes -OSCustomizationSpec $custspec
Can anyone confirm if it's a bug? I have put quite an amount of time into this issue so now I'd like to know if I'm up against the impossible here
Thanks,
Kim
Have a look at KB1016878.
Does the bypass from that KB perhaps solve your problem ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have a look at KB1016878.
Does the bypass from that KB perhaps solve your problem ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I didn't go for the workaround as I had no problem setting the gateway manually so I got the hotfix from the article and it fixed the issue.
Thanks a lot,
Kim