PowerCLI

 View Only
  • 1.  Assign a static IP address to newly deployed VMs

    Posted Sep 13, 2012 06:42 PM

    Does anyone have any good way to deploy VMs from templates and asssign and configure a static IP address?



  • 2.  RE: Assign a static IP address to newly deployed VMs

    Posted Sep 13, 2012 06:43 PM

    Thank you in advance for your help!



  • 3.  RE: Assign a static IP address to newly deployed VMs
    Best Answer

    Posted Sep 13, 2012 06:56 PM

    Have you looked into Customization and Specification Manager? When used with deploying VM from templates, you can make it ask the user for static IP address.



  • 4.  RE: Assign a static IP address to newly deployed VMs

    Posted Sep 13, 2012 07:54 PM

    I am currently using the custimization specifications for new deployments and it prompts for the IP; however, I am looking for an automated method of assigning IP addresses to new VMs.



  • 5.  RE: Assign a static IP address to newly deployed VMs

    Posted Sep 13, 2012 07:56 PM

    In your screen shot there is an option that is greyed out called "Use an application configured on the vCenter Server to generate the IP address."  This is the type of solution that I am looking for.



  • 6.  RE: Assign a static IP address to newly deployed VMs

    Posted Sep 14, 2012 04:32 AM


  • 7.  RE: Assign a static IP address to newly deployed VMs

    Posted Sep 18, 2012 01:02 PM

    This is what I use to get an IP address, create the customization spec, and clone from the template.

    #vlan125   
        if ($vlan -eq 'vlan125'){
            $valid = $true
            foreach($i in 254..3)
            {
                $ip = "111.111.1.$i"
                If (Test-Connection -comp $ip -count 1 -quiet) {
                    write-host -ForegroundColor Green "Computer online $ip"
                }
                Else {
                    "Computer offline $ip"
                    try{
                        $HostName = [System.Net.Dns]::GetHostByAddress($ip).HostName
                        $hostname
                    }
                    catch{
                        write-host -ForegroundColor Red "This is the $ip that will be used.";
                        $valid=$false;
                        break
                    }
                }
            }
            if ($valid -eq $true){
                write-host -ForegroundColor Red "Alert there are no available IP address for $vlan"
            }
            $SUB = '255.255.255.0'
            $Gateway = '111.111.11.1'
        }


    $custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows `
    -OrgName “WORK” -FullName "$LocalAdminAccount" -Domain “WORK.HOME” `
    -DomainUsername $usr -DomainPassword $pss -LicenseMode PerSeat `
    -AdminPassword "This is the password" -NamingScheme Fixed -NamingPrefix $newVMName -TimeZone 035 -ChangeSid

    #Modify the default network configuration settings
    $custSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping `
    -IpMode UseStaticIP -IpAddress $IP -SubnetMask $SUB `
    -Dns $DNS -DefaultGateway $Gateway -Wins $WINS

    #Deploy a VM from a template
    $clonetask = New-VM -Name "$newVMName" -Template "$template" -VMHost "$tgtEsxName" -Datastore "$tgtDatastoreName" `
    -OSCustomizationSpec $custSpec



  • 8.  RE: Assign a static IP address to newly deployed VMs

    Posted Oct 03, 2012 11:39 AM

    Hi

    Can you provide some step by step on how your implementation looks like?

    Regards

    Tatsumi