I am having a hard time setting the antiaffinity rule on new vm builds with powercli.
I keep getting this error:
New-VM Invalid disk identifier '1' in S drsVMDiskAntiAffinityRule. Please specify a correct disk identifier when creati ng the SdrsVMDiskAntiAffinityRule (by passing the HardDisk object(s)).
here is the code:
$advancedOption = New-object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule' 1,2
$DSCluster = Get-datastorecluster -name $DStore; New-VM -Name $vmname -advancedoption $advancedoption -OSCustomizationSpec $Customization -Template $Template -VMhost $VMHost -Datastore $DSCluster -RunAsync
I have tried it with a template that 1 disk or 2 disks and I get hte same result.
Thanks for any help!
here is the option for $advancedoption
DiskIdentifier
--------------
{1, 2}
That seems to work for me when I don't use a template.
Is that working for you as well ?
Is the datastorecluster enabled for SDRS ?
$datastoreCluster = Get-DatastoreCluster -Name DSC1
$advancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule' 1,2 New-VM -Name TestVM -DiskMB 40000,40000,40000 -Datastore $datastoreCluster -AdvancedOption $advancedOption -VMHost (Get-VMHost MyEsx)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
that works for me too.
the datastore cluster is enabled for SDRS.
Will the advanced options not work with a template? or do i need to modify the template?
I'm afraid I don't know, I'll have to play around with anti-affinity rules and templates myself a bit.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there a way to set the default vmdk affinity rule to false on the datastore cluster? We disabled it for the vm affinity rule and i am able to clone from a template. The Vm affinity rule is disabled so no sdrs rules got applied, but keep vmdk's together option is still checked for the vm on the cluster.
any thoughts?