Automation

 View Only
  • 1.  Remove or Omit Default Gateway from 2nd NIC

    Posted Aug 11, 2016 04:51 PM

    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



  • 2.  RE: Remove or Omit Default Gateway from 2nd NIC

    Posted Aug 11, 2016 05:52 PM

    Can't you change the gateway entry with the Set-OSCustomizationNicMapping cmdlet?

    Or doe that also require a Getway?



  • 3.  RE: Remove or Omit Default Gateway from 2nd NIC

    Posted Aug 11, 2016 06:03 PM

    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.



  • 4.  RE: Remove or Omit Default Gateway from 2nd NIC
    Best Answer

    Posted Aug 11, 2016 06:21 PM

    Then you will be forced to use the API method directly (like in the thread you already pointed to) I'm afraid.



  • 5.  RE: Remove or Omit Default Gateway from 2nd NIC

    Posted Aug 11, 2016 06:22 PM

    Alright, thanks for the information.