how do I deploy more than 1 vm from a template?
I am using this command
You could make a .csv file New-Vms.csv with all the information you need. Like this:
Name,VMHost,Template,Datastore
print0001,esx7.domain.com,2003ENTR2_SP2_Tmpt,"LUN 24"
print0002,esx8.domain.com,2003ENTR2_SP2_Tmpt,"LUN 25"
With this New-VMs.csv file you can create all the new virtual machines from a template with:
Import-Csv -Path New-VMs.csv | ` ForEach-Object { New-VM -VMHost $_.VMHost -Name $_.Name -Template $_.Template -Datastore $_.Datastore }Regards, Robert
This should get you started.
Takes a fixed format CSV and pumps out clones from a template. Easily modified to do clones of a VM or create new VMs. Some of the restrictions mentioned in the notes appear to be fixed with VMware ESX v4.1.
can i do this from the vMA?
Sorry, but I have no idea.
this is my command
Looks as if your .csv file doesn't have a VMHost column.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have vmhost in there. but when I use -Template It gives an error.
Ok, I think I see what is wrong.
You are trying to use the parameterset Template but in that parameterset you can't use -MemoryMB and -NumCPU.
If you want to make changes to your template you have to use the -OSCustomizationSPec parameter.
If you look at the doc for the New-VM cmdlet you'll notice that under the Syntax header there are 4 different parametersets.
Due to the -Template parameter you fall in the Template parameterset and your other parameters have to come from the 3th entry (Template parameterset).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I handle this by first creating the VM with –template and –oscustomizationspec with a simple spec. Then separately I do set-vm for the cpu and ram, and I also set the VLAN, custom attributes, and a few other things. For all of them I pull the data from the CSV file.
-Chris
Hi
but my template is already a syspreped template so I dont see any need for a OScustomizationspec paramenter.
But when I created one anyway and used this
Can't you create the new guest from the the template and after the creation use the Set-VM to change the CPU count and the memory ?
Set-VM -NumCpu $numCPU -MemoryMB $memoryMB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference