#Spawn vm's from templates
$numVMs = 10
$template = Get-Template "Template_testvm"
$EsxServer = Get-VMHost vcloud-esx1.lab.loc
#$spec = Get-OSCustomizationSpec "Windows 2008 R2 Standard"
#New-VM -Name VM2 -Template $template -VMHost $host -OSCustomizationSpec $spec
#Loop through every host
#foreach($EsxServer in Get-VMHost)
#{
"Adding Test VM to $EsxServer"
$counter = 1
while ($counter -lt ($numVMs+1))
{
#New-VM -Name TESTVM$counter-$EsxServer -VMHost $EsxServer -Datastore (Get-Datastore | where { $_.FreeSpaceMB -gt "85000" -and $_.Name -notlike "*Local*"} | Select-Object -First 1) -Template $template -RunAsync
New-VM -Name TESTVM$counter-$EsxServer -VMHost $EsxServer -Datastore (Get-Datastore | where { $_.FreeSpaceMB -gt "85000" -and $_.Name -like "*DS1*"} | Select-Object -First 1) -Template $template -RunAsync
#Start-Sleep -Seconds 30
$counter++
}
#}
Saturday, May 4, 2013
Spawning Test VMs
I wrote a powershell the script the other day that I would like to share. This script spawns test virtual machines from a template for lab testing.
Labels:
powercli,
powershell,
test vm,
vmware
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment