The script is working so far.
The next challenge is that i have 2 cluster, each in a different site. Each site is active. each cluster has the same resourcepools and the resourcepools have the same names + the -<sitecode>. So each resourcepool is unique.
The script clones a template and put's the vm in a resourcepool on a cluster. But if i don't want to put a vm in a resourcepool, i looked at the SDK concerning VirtualMachineRelocateSpec.
In the VirtualMachineRelocateSpec there is a line that when you clone a template to vm, you must specify a resourcepool, but how to do that if i want to use the cluster default resourcepool?
The code for getting the resourcepool is:
#RESOURCE POOL FROM CLUSTER
$pool = get-resourcepool $vmpool
$poolview = get-view $pool.id
$vmrSpec.pool = $poolview.moref
But how to use the default resourcepool of a cluster?
Thanks in advance.