Does anyone have any good way to deploy VMs from templates and asssign and configure a static IP address?
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.
Thank you in advance for your help!
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.
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.
Here is documentation that can guide you to get the custom script working.
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
Hi
Can you provide some step by step on how your implementation looks like?
Regards
Tatsumi