You can create a VM-VMHost DRS rule within a cluster after creating a VM DRS cluster group and a VMHost DRS cluster group.

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 DRS cluster group.
    $vms = Get-VM "VM1", "VM2"
  2. Get the hosts for the VMHost DRS cluster group.
    $vmHosts = Get-VMHost "hostname1", "hostname2"
  3. Get the cluster where you want to create the rule.
    $cluster = Get-Cluster "MyCluster"
  4. Create a VM DRS cluster group.
    $vmGroup = New-DrsClusterGroup -Name "MyVmsDrsClusterGroup" -VM $vms -Cluster $cluster
  5. Create a VMHost DRS cluster group.
    $vmHostGroup = New-DrsClusterGroup -Name "MyVmHostsDrsClusterGroup" -VMHost $vmHosts -Cluster $cluster
  6. Create the VM-VMHost DRS rule by using the newly created VM DRS cluster group and VMHost DRS cluster group.
    New-DrsVMHostRule -Name "MyDrsRule" -Cluster $cluster -VMGroup $vmGroup -VMHostGroup $vmHostGroup -Type "MustRunOn"