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

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.


Get the virtual machines for the VM-VM DRS rule.

$affinityVMs = Get-VM "VM1", "VM2"

Get the cluster where you want to create the rule.

$cluster = Get-Cluster "MyCluster"

Create the VM-VM DRS rule within the MyCluster cluster.

New-DrsRule -Cluster $cluster -Name "AffinityRule1" -KeepTogether $true -VM $affinityVMs