Create multiple VM’s by cloning template

Because I needed to create multiple VM’s from a template I decided to have a look into the PowerCLI command for this.  I created a text file with pre-given names, called D:<file>.txt, for each item in this list I create a new VM according to template <template> on <vmhost> and <datastore>.  To put the VM’s in a specific location I use the “-location”. With the option “RunAsync” it fires the commands and goes to the next one instead of waiting for the first job to complete before proceeding to the next one.

foreach ($vm in (GC D:<file>.txt)){

New-VM -name $vm -Location <location> -Template <template>`
-vmhost <vmhost> -Datastore <datastore> -RunAsync
}