New-DeployRule Command | Vmware PowerCLI Reference

New-DeployRule

Creates a new rule with the specified items and patterns. The items specify what should be associated with an ESXi host and the patterns specify which ESXi hosts the rule applies to. A rule on its own does not affect anything. The rule must first be added to the working rule set in order to place it in context with the other rules in the system. Since multiple rules can match a single host, the rule set is used to rank the rules. Items in higher ranking rules are preferred over items in lower ranking rules. Only one item of a particular type will be associated with the host. For example, if two rules in a rule set have host profiles, only the profile in the higher ranking rule will be used. Alternatively, if one rule has a host profile and the other rule has an image profile, both rules will have an affect. You must have the "AutoDeploy.Rule.Create" privilege on the root folder of vCenter Server to use this cmdlet.

Syntax

New-DeployRule
-Item < VIObjectCore[] >
-Name < String >
-Pattern < String[] >
[-NoHostSeeding ]
[-ProgressAction < ActionPreference > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
Item VIObjectCore[] named
  • pipeline
Item the rule should apply to the hosts. Can be an image profile, a script bundle, a host profile, or a folder or cluster on the vCenter Server system to add the host to.
required
Name String named
Name of the new rule.
required
Pattern String[] named
Set of hosts the new rule should apply to. Pattern strings use the following syntax: <attr>==<value> Adds a pattern that exactly matches the specified value against the specified attribute. Use this syntax if you need to match a string that contains a comma. <attr>=<Val1 >[,val2,... ,valN] Adds a pattern that matches against the comma-separated list of values. Supported value types are: string Exact string match <ip1>-<ip2> Range of IPv4 addresses.
optional NoHostSeeding SwitchParameter named
Specify that the image profile associated with the rule should not support host seeding. Hosts booting from that rule cannot be used to seed other hosts in a vLCM environment.
optional ProgressAction ActionPreference named
New-DeployRule
-AllHosts
-Item < VIObjectCore[] >
-Name < String >
[-NoHostSeeding ]
[-ProgressAction < ActionPreference > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
AllHosts SwitchParameter named
Specify AllHosts to apply the new rule to all hosts managed by VMware Auto Deploy. Hosts are managed by VMware Auto Deploy if the DHCP server directs them to the Auto Deploy TFTP configuration file.
required
Item VIObjectCore[] named
  • pipeline
Item the rule should apply to the hosts. Can be an image profile, a script bundle, a host profile, or a folder or cluster on the vCenter Server system to add the host to.
required
Name String named
Name of the new rule.
optional NoHostSeeding SwitchParameter named
Specify that the image profile associated with the rule should not support host seeding. Hosts booting from that rule cannot be used to seed other hosts in a vLCM environment.
optional ProgressAction ActionPreference named

Output

Examples

Example 1

$rule = New-DeployRule -Name "defaultFolder" -Item "NewHosts" -AllHosts

Create a rule that places all hosts in the folder named "NewHosts".

Example 2

$img = Get-ESXImageProfile -Name "My ESXi 5.0"
$rule = New-DeployRule -Name "testrule" -Item $img -Pattern  "vendor=Acme","vendor==VMware, Inc.","ipv4=192.168.1.10-192.168.1.20"

Create a rule that assigns the image profile named "My ESXi 5.0" to hosts that match a set of vendors and are in a particular IPv4 range.

Example 3

$bundle = Get-ScriptBundle -Name "testbundle"
$rule = New-DeployRule -Name "testrule" -Item $bundle -Pattern  "vendor=Acme","vendor==VMware, Inc.","ipv4=192.168.1.10-192.168.1.20"

Create a rule that assigns the script bundle named "testbundle" to hosts that match a set of vendors and are in a particular IPv4 range.

Related Commands

DeployRule

Adds one or more rules to the rule set.

Clones an existing rule.

Gets a DeployRule object.

Creates a new rule.

Removes a rule from the working rule set.

Updates an existing rule.

DeployRuleSet

Gets the current working rule set or the current active rule set.

Sets the list of rules in the working rule set.

DeployRuleSetCompliance

Remediate any non-compliant associations discovered by Test-DeployRuleSetCompliance

Checks whether hosts are compliant with rules.