Hyper-V cluster affinity with Powershell


In a Hyper-V cluster environment it is sometimes needed to split servers on different Hyper-V hosts.

For example, is you have two Remote Desktop Servers (RDS) for fault tolerance, you don’t want them both running on the same Hyper-V host. Is this host fails, both servers are down.

To split those server over multiple Hyper-V hosts you must use Hyper-V Anti-Affinity rules. They cannot be set in the GUI of Hyper-V. For this you need to use the System Center Virtual Machine Manager (SCVMM) or you can use Powershell off course :-).

To create a Hyper-V cluster affinity with Powershell, you need to set up a connection to a Hyper-V host:

Then you must create AntiAffinities for the roles you need to split. In this case for Mailbox (MBX), Client Access servers (CAS) and Remote desktop (RDS)

Then you connect the servers to those Affinities Class Names

Now, when this is set, two servers in the same affinity rule will not be active on the same Hyper-V host, if there are enough servers available.

Leave a Reply

Your email address will not be published. Required fields are marked *