Dear Team,
Daily we have to deploy 100+ VMs, Just wanted to know how we can automate the process.
We have already created 2 customization, one will be used for windows and other for Linux, If we are deploying Linux VM through script so it should select existing LINUX customization and for Windows it should select existing Windows Customization.
Sript should ask below details
-VMname or it should take it from notepad/csv file
-We will keep ip details in notepad/csv file so it should assign ips to new VM from that file
-ClusterName where we have to deploy a VM
-DatastoreName where to deploy a VM.
After entering above input VM deployment task should start. if we have this type of script handy then any1 can deploy VMs independently.
Thanks in Advance.
regards
Mohammed Ahmed
Do you already have some script ready?
Or are you asking for a complete script from scratch?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Complete script from scratch ![]()
Ok, let's start with this.
Do you use an OSCustimzationSpec when creating VMs from a Template?
$vmName = Read-Host -Prompt 'Enter VM Name'
$clusterName = Read-host -Prompt 'Enter Cluster Name'
$datastoreName = Read-host -Prompt 'Enter Datastore Name'
$osType = Read-Host -Prompt 'What shall be the guest OS type? Windows(W) or Linux(L)'
if($osType -match "W"){
$template = 'WindowsTemplate'
}
else{
$template = 'LinuxTemplate'
}
New-VM -Name $vmName -Template $template -ResourcePool $clusterName -Datastore $datastoreName
I'm not sure how you intend to configure the network in the Guest OS?
Do your Templates have VMware Tools installed?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a ton for your help ![]()
Yes we are using customization , 2 already created one for windows and for LINUX. In the above script request you to add it should select respective existing customization based on the OS type.
You can add those OSCustomizatoinSpecs like this.
You'll have to update the names for your environment.
$vmName = Read-Host -Prompt 'Enter VM Name'
$clusterName = Read-host -Prompt 'Enter Cluster Name'
$datastoreName = Read-host -Prompt 'Enter Datastore Name'
$osType = Read-Host -Prompt 'What shall be the guest OS type? Windows(W) or Linux(L)'
if($osType -match "W"){
$template = 'WindowsTemplate'
$osCust = 'Windows'
}
else{
$template = 'LinuxTemplate'
$osCust = 'Linux'
}
New-VM -Name $vmName -Template $template -OSCustomizationSpec $osCust -ResourcePool $clusterName -Datastore $datastoreName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
