Using the DRS affinity and anti-affinity rules

In this section, we will discuss the advanced settings of a cluster. We can use the following cmdlets for this section:

  • Get-DrsRule
  • New-DrsRule
  • Remove-DrsRule
  • Set-DrsRule

First, we will create a new anti-affinity rule with the two Test1 and Test2 VMs that we created for this purpose. We want to always keep them separate in such a way that they will not run on a single host at any point of time. For this, we will use the New-DrsRule cmdlet to create a rule. We will use the following command for this:

PS C:\> New-DrsRule –Cluster 'Lab Cluster' –Name `  antiAffinityTest1 -KeepTogether $false –VM Test1, Test2

The result of the preceding command is shown in the following screenshot:

Note the warning about the ...

Get Mastering PowerCLI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.