Reply to Message

View discussion in a popup

Replying to:
romatlo
Enthusiast
Enthusiast

Thank you for the feedback!

I ended up finding a solution based on your feedback and others.

Here is the script I ended up with that is working well so far for what I need it for immediately.

Thanks again!

$VMHOSTS = Get-Cluster 'Westcreek' | Get-VMHOST | Sort name

$NumVMs = 3

$NEW_VMS = (1..$NumVMs)

$myTemplate = Get-Template -Name Win7temp

$mySpecification = Get-OSCustomizationSpec -Name win7

$i = 0

ForEach ($VM in $NEW_VMS) {

New-VM -Name test$($VM) -VMHost $($VMHOSTS[$i]) -ResourcePool Hosts -Template $myTemplate -OSCustomizationSpec $mySpecification -Datastore VMs2 -DiskStorageFormat Thin

$i++

If ($i -ge $VMHOSTS.count) {$i=0}

}