4 Replies Latest reply on Aug 11, 2016 11:22 AM by macdougall

    Remove or Omit Default Gateway from 2nd NIC

    macdougall Novice

      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