I have written few commands below on setting up a new virtual machine on a specfic vmhost and then attaching iso image to the cd drive and then powering on VM. But I wanted to find out how I can combine all these commands into a function, then run the function by giving a parameter which is the virtual machine and also maybe the iso image.
The command for creating a VM on a specific host I used was :
get-vmhost 'VMhost' | new-vm -name 'name -datastore (get-datastore 'datastore) -diskmb ( 8GB / 1MB ) -memoryMB ( 1gb / 1mb )
get-vm 'name' | new-cddrive -isopath $isopath -startconnected
Start-VM 'name'
How can you combine the above in a script by applying parameters such as name and iso path (if that is possible).
Any advise, or is there is downloadable script for creating VM's