Q. How do I configure anti-affinity in my Failover Cluster?
A. Anti-affinity enables a collection to be created which contains VMs that the cluster will attempt to keep on separate nodes. This is important when you have multiple instances of a service running in a cluster and want to ensure they are distributed over multiple nodes to ensure service availability even if a node fails. In the example below I add 3 VMs to an anti-affinity group which will then ensure where possible they will each run on different nodes in the cluster.
Get-ClusterGroup | Select AntiAffinityClassNames $ATAAntiAffinity = New-Object System.Collections.Specialized.StringCollection $ATAAntiAffinity.Add("ATA Gateway") (Get-ClusterGroup -Name infra-atagw1).AntiAffinityClassNames = $ATAAntiAffinity (Get-ClusterGroup -Name infra-atagw2).AntiAffinityClassNames = $ATAAntiAffinity (Get-ClusterGroup -Name infra-atagw3).AntiAffinityClassNames = $ATAAntiAffinity