Hi - I'm looking for a script that will create multiple vm's from a content library template or ova. Where I can feed the script unique vm names, cpu, memory, choose the datastore to place the vm on as well as the cluster or host, and choose the customization spec to use, and feed it the details from a csv. Is there a good one out there?
Thanks,
Pete
I don't know of any scripts, but basically, this is just 3 cmdlets: Get-ContentLibraryItem, Import-Csv and New-VM.
Something like this for example
$templateName = 'MyTemplate'
$template = Get-ContentLibraryItem -Name $templateName
Import-Csv -Path .\vm.csv -PipelineVariable vm |
ForEach-Object -Process {
$sVM = @{
ContentLibraryItem = $template
Name = $row.VMName
Datastore = $row.Datastore
DiskGB = $row.DiskGB
MemoryGB = $row.MemoryGB
Portgroup = $row.PortgroupName
NumCPU = $row.NumCPU
OSCustomizationSpec= $row.OSCustomizationSpec
# Pick one: ResourcePool allows for cluster,resourcepool, vmhost
#ResourcePool = $row.ResourcePool
#VMHost = $row.VMHost
}
New-VM @SVM
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I don't know of any scripts, but basically, this is just 3 cmdlets: Get-ContentLibraryItem, Import-Csv and New-VM.
Something like this for example
$templateName = 'MyTemplate'
$template = Get-ContentLibraryItem -Name $templateName
Import-Csv -Path .\vm.csv -PipelineVariable vm |
ForEach-Object -Process {
$sVM = @{
ContentLibraryItem = $template
Name = $row.VMName
Datastore = $row.Datastore
DiskGB = $row.DiskGB
MemoryGB = $row.MemoryGB
Portgroup = $row.PortgroupName
NumCPU = $row.NumCPU
OSCustomizationSpec= $row.OSCustomizationSpec
# Pick one: ResourcePool allows for cluster,resourcepool, vmhost
#ResourcePool = $row.ResourcePool
#VMHost = $row.VMHost
}
New-VM @SVM
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc - I'll give that a try today.