With the vSphere PowerCLI its possible to deploy multiple virtual machines from templates defined in a CSV file.
The CSV file needs contain the following column headings exactly for the below script to work.

Name
Template
DestinationHost
CustomSpec
NumCpu
MemoryMB

 

 

You will need an existing template you have created prior and also a guest OS customisation specification.

 

 


Connect-VIServer vcenter1.vmadmin.co.uk


$VirtualMachinesCSV = "C:\VMsFromTemplate.csv"
$strDescription = "Created from template and CSV by Andy Barnes"

$VirtualMachinesDetails = Import-CSV $VirtualMachinesCSV
$VirtualMachinesDetails | %{ New-VM -Name $_.Name -Template $(Get-Template  $_.Template) -VMHost $(Get-VMHost $_.DestinationHost) -OSCustomizationSpec $(Get-OSCustomizationSpec $_.CustomSpec) }
$VirtualMachinesDetails | %{ Set-VM -VM $_.Name -NumCpu $_.NumCpu -MemoryMB $_.MemoryMB -Description $strDescription -Confirm:$false }
$VirtualMachinesDetails | %{ Start-VM -VM $_.Name -Confirm:$false }




Share this blog post on social media:

Social Links

Disclaimer

All advice, installation/configuration how to guides, troubleshooting and other information on this website are provided as-is with no warranty or guarantee. Whilst the information provided is correct to the best of my knowledge, I am not reponsible for any issues that may arise using this information, and you do so at your own risk. As always before performing anything; check, double check, test and always ensure you have a backup.

Copyright ©2016 Andy Barnes - Please do not copy any content including images without prior consent!

Designed and Hosted by Andy Barnes