You can create a VM-VM DRS affinity rule within a cluster.

Prerequisites

  • Verify that you are connected to a vCenter Server system.
  • Verify that virtual machines and hosts exist within a cluster with enabled DRS in the vCenter Server environment.

Procedure

  1. Get the virtual machines for the VM-VM DRS rule.
    $affinityVMs = Get-VM "VM1", "VM2"
  2. Get the cluster where you want to create the rule.
    $cluster = Get-Cluster "MyCluster"
  3. Create the VM-VM DRS rule within the MyCluster cluster.
    New-DrsRule -Cluster $cluster -Name "AffinityRule1" -KeepTogether $true -VM $affinityVMs