I'm deploying multiple VMs with 2 NICs each. My script has the following lines to set the IP, Subnet and Gateway:
$specClone = New-OScustomizationSpec -Spec $custspec -type nonpersistent
$specClone | New-oscustomizationnicmapping -IpMode UseStaticIP -Ipaddress $ip1 -SubnetMask $subnet1 -DefaultGateway $gateway1 -Dns "0.0.0.0" -Position 1
$specClone | New-oscustomizationnicmapping -IpMode UseStaticIP -Ipaddress $ip2 -SubnetMask $subnet2 -DefaultGateway $gateway2 -Dns "0.0.0.0" -Position 2
Set-VM -Name $name -oscustomizationspec $specClone -erroraction silentlycontinue -runasync -confirm:$false
My problem is that oscustomizationnicmapping by default requires that you enter a default gateway for the 2nd NIC but I don't want to do this for my configuration.
I found an older article here, Deploying a VM with Multiple NICs in PowerCLI., where LucD mentions you can create your own adaptermapping object without defining a gateway.
Is there an easier way to achieve omitting the 2nd default gateway that could be implemented with the "new-oscustomizationnicmapping" method that I'm currently using?
Or do I have to go the more in-depth route and create custom "adaptermapping" objects to get this result?
Thanks,
Bruce
Then you will be forced to use the API method directly (like in the thread you already pointed to) I'm afraid.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can't you change the gateway entry with the Set-OSCustomizationNicMapping cmdlet?
Or doe that also require a Getway?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'd like to leave the gateway off of the 2nd NIC completely, but when you use static ip to configure it forces you to define a gateway.
Then you will be forced to use the API method directly (like in the thread you already pointed to) I'm afraid.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Alright, thanks for the information.