You can deploy multiple virtual machines with a single network adapter and configure the deployed virtual machines to use static IP addresses by applying a customization specification.

Prerequisites

Verify that you have defined a list of static IP addresses in a CSV file.

Procedure

  1. Define the naming convention for the virtual machines.
    $vmNameTemplate = "VM-{0:D3}"
  2. Save the cluster in which the virtual machines should be created into a variable.
    $cluster = Get-Cluster MyCluster
  3. Save the template on which the virtual machines should be based into a variable.
    $template = Get-Template MyTemplate
  4. Create the virtual machines.
    $vmList = @()
    	
    for ($i = 1; $i –le 100; $i++) {
        $vmName = $vmNameTemplate –f $i
        $vmList += New-VMName $vmName –ResourcePool $cluster –Template $template
    }
  5. Save the static IP addresses from the stored CSV file into a variable.
    $staticIpList = Import-CSV C:\StaticIPs.csv
  6. Create the customization specification.
    $linuxSpec = New-OSCustomizationSpecName LinuxCustomization –Domain vmware.com –DomainUsername "your_domain_username" –DomainPassword "your_domain_password" –DnsServer "192.168.0.10", "192.168.0.20" –NamingScheme VM –OSType Linux
  7. Clone the customization specification to a nonpersistent type.
    $specClone = New-OSCustomizationSpecSpec $linuxSpec –Type NonPersistent
  8. Apply the customization specification to each virtual machine.
    for ($i = 0; $i –lt $vmList.Count; $i++) {
        # Acquire a new static IP from the list
        $ip = $staticIpList[$i].IP
    
        # The specification has a default NIC mapping – retrieve it and update it with the static IP
        $nicMapping = Get-OSCustomizationNicMappingOSCustomizationSpec $specClone
        $nicMapping | Set-OSCustomizationNicMappingIpMode UseStaticIP –IpAddress $ip –SubnetMask "255.255.252.0" –DefaultGateway "192.168.0.1"
    
        # Apply the customization
        Set-VMVM $vmList[$i] –OSCustomizationSpec $specClone –Confirm:$false
    }