Hi,
I'm trying to create a script that clones from one VMware-Template as many VM-environments as I need.
I found a script online which should do that:
____________________________________
Connect-VIServer -Server 192.168.0.1
Get-VMHost
$host1 = "192.168.0.2"
$template = "template1"
$datastore = "data1"
$customization = "templtest"
for($i = 1; $i -le 3; $i++)
{
$tempvm = "vServer-"+$i
$array += $tempvm
}
foreach ($vm in $array)
{
$vm=New-VM -Name $vm -Template $template -Host $host1 -Datastore $datastore -OSCustomizationSpec $customization -Confirm:$false
}
_____________________________
for example, that script should create 3 VMs of template1 with the names: vServer-1, vServer-2 and vServer3.
But it only creates one VM with the name vServer-1vServer-2vServer-3.
Can somebody help me with that problem?
Is there something wrong in the for-statement?
thanks in anticipation,
Alex
Hi Alex,
Before the for statement you have to insert the following line:
$array = @()
This will initialize the $array variable as an empty array.
Regards, Robert
Message was edited by: RvdNieuwendijk
Hi Alex,
Before the for statement you have to insert the following line:
$array = @()
This will initialize the $array variable as an empty array.
Regards, Robert
Message was edited by: RvdNieuwendijk
oh yes, now it works, thank you very much!!!