Hi,
Our Windows templates have 2 NICs and we do not use a default gateway on the second NIC.
Virtual centre allows us to use a customisation where the second NIC does not use a gateway and it works fine.
We are trying to automate the template deployment and customisation.
However using Set-OSCustomizationNicMapping -OSCustomizationNicMapping using a static IP the DefaultGateway option is mandatory.
Is there any work around for this please.
All I can think is not to use the customisation specification for the 2nd NIC and just leave on DHCP and then try and configure it later but this would not be a straightforward task and surely it is something we should be able to do using PowerCLI.
Thanks.
Yes, the Set-OSCustomizationSpecNicMapping cmdlet unfrotunately doesn't allow all configuration options the Web Client allows.
The method you envisage to fix that problem is a valid one.
But it would require that part of your VM's customization is done outside the OSCustomization mechanism, which is a bit of shame.
Another alternative is to use the methods available on the CustomizationSpecManager.
There you have access to the same functionality as in the Web Client.
You could do something like this
$osCustName = 'Test'
$osSpec = New-OSCustomizationSpec -Name $osCustName -Type Persistent -OSType Windows -Workgroup MyGroup -FullName 'Administrator.Test' -OrgName 'Test'
# Remove default NIC
Get-OSCustomizationNicMapping -OSCustomizationSpec $osSpec | Remove-OSCustomizationNicMapping -Confirm:$false
# NIC #1
New-OSCustomizationNicMapping -OSCustomizationSpec $osSpec -IpMode UseStaticIP -IpAddress 192.168.1.1 -SubnetMask 255.255.255.0 -DefaultGateway 192.168.1.254 -Dns 192.168.1.100
# Nic #2
New-OSCustomizationNicMapping -OSCustomizationSpec $osSpec -IpMode UseStaticIP -IpAddress 192.168.2.1 -SubnetMask 255.255.255.0 -DefaultGateway 192.168.2.254 -Dns 192.168.2.100
$si = Get-View ServiceInstance
$custMgr = Get-View -Id $si.Content.CustomizationSpecManager
$spec = $custMgr.GetCustomizationSpec($osCustName)
$spec.Spec.NicSettingMap[1].Adapter.Gateway = ''
$custMgr.OverwriteCustomizationSpec($spec)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, the Set-OSCustomizationSpecNicMapping cmdlet unfrotunately doesn't allow all configuration options the Web Client allows.
The method you envisage to fix that problem is a valid one.
But it would require that part of your VM's customization is done outside the OSCustomization mechanism, which is a bit of shame.
Another alternative is to use the methods available on the CustomizationSpecManager.
There you have access to the same functionality as in the Web Client.
You could do something like this
$osCustName = 'Test'
$osSpec = New-OSCustomizationSpec -Name $osCustName -Type Persistent -OSType Windows -Workgroup MyGroup -FullName 'Administrator.Test' -OrgName 'Test'
# Remove default NIC
Get-OSCustomizationNicMapping -OSCustomizationSpec $osSpec | Remove-OSCustomizationNicMapping -Confirm:$false
# NIC #1
New-OSCustomizationNicMapping -OSCustomizationSpec $osSpec -IpMode UseStaticIP -IpAddress 192.168.1.1 -SubnetMask 255.255.255.0 -DefaultGateway 192.168.1.254 -Dns 192.168.1.100
# Nic #2
New-OSCustomizationNicMapping -OSCustomizationSpec $osSpec -IpMode UseStaticIP -IpAddress 192.168.2.1 -SubnetMask 255.255.255.0 -DefaultGateway 192.168.2.254 -Dns 192.168.2.100
$si = Get-View ServiceInstance
$custMgr = Get-View -Id $si.Content.CustomizationSpecManager
$spec = $custMgr.GetCustomizationSpec($osCustName)
$spec.Spec.NicSettingMap[1].Adapter.Gateway = ''
$custMgr.OverwriteCustomizationSpec($spec)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Brilliant that worked a treat.
Thanks for the assistance.
Cheers,
Nigel.