New-DrsRule Command | Vmware PowerCLI Reference

New-DrsRule

This cmdlet creates a new DRS rule. Each rule defines the virtual machines that can run on the same host (affinity rule) or must run on different hosts (anti-affinity rule).

Syntax

New-DrsRule
[ -Cluster ] < Cluster >
-KeepTogether < Boolean >
-Name < String >
[-Enabled < Boolean > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
Cluster Cluster 1
  • pipeline
  • wildcards
Specifies the cluster for which the new DRS rule applies. Passing multiple values to this parameter is obsolete.
required
KeepTogether Boolean named
If the value of this parameter is $true, the new DRS rule is an affinity rule. If the value is $false, the DRS rule is an anti-affinity rule.
required
Name String named
Specifies a name for the new DRS rule.
required
VM VirtualMachine[] named
  • wildcards
Specifies the virtual machines that are referenced by the new DRS rule.
optional Enabled Boolean named
If the value of this parameter is $true, the new DRS rule is enabled for the specified clusters. If the value is $false, it is deactivated.
optional RunAsync SwitchParameter named
Indicates that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help About_RunAsync" in the VMware PowerCLI console.
optional Server VIServer[] named
  • pipeline
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.

Output

VMware.VimAutomation.ViCore.Types.V1.Cluster.DrsVMAffinityRule

Examples

Example 1

New-DrsRule -Cluster $cluster -Name antiAffinityRule1 -KeepTogether $false -VM $antiAffinityVMs

Creates a new DRS rule for the cluster saved in the $cluster variable with the specified parameters.

Related Commands

DrsClusterGroup

This cmdlet retrieves DRS cluster groups for the specified cluster, VM, or VM host.

This cmdlet creates either a VM or VM host DRS cluster group, depending on the used parameter set.

This cmdlet removes the specified DRS cluster groups from the cluster on which it resides.

This cmdlet adds or removes either virtual machines or VM hosts to or from the specified DRS cluster group, depending on the used parameter set.

DrsRecommendation

This cmdlet retrieves the available DRS recommendations from the provided clusters.

This cmdlet applies the specified DRS recommendations.

DrsRule

This cmdlet retrieves the list of DRS rules for the specified clusters.

This cmdlet creates a new DRS rule.

This cmdlet removes the specified DRS rules.

This cmdlet modifies an existing DRS rule.

DrsVMHostRule

This cmdlet retrieves VM to VMHost DRS rules that match the specified filters.

This cmdlet creates a new VM to VMHost DRS rule.

This cmdlet removes the specified VM to VMHost DRS rule.

This cmdlet modifies the specified VM to VMHost DRS rule.