Add-DhcpServerv4Policy

Add-DhcpServerv4Policy

Adds a new policy either at the server level or at the scope level.

Syntax

Parameter Set: Add0
Add-DhcpServerv4Policy [-Name] <String> [-Condition] <String> [-AsJob] [-CimSession <CimSession[]> ] [-CircuitId <String[]> ] [-ClientId <String[]> ] [-ComputerName <String> ] [-Description <String> ] [-Enabled <Boolean> ] [-Fqdn <String[]> ] [-LeaseDuration <TimeSpan> ] [-MacAddress <String[]> ] [-PassThru] [-ProcessingOrder <UInt16> ] [-RelayAgent <String[]> ] [-RemoteId <String[]> ] [-ScopeId <IPAddress> ] [-SubscriberId <String[]> ] [-ThrottleLimit <Int32> ] [-UserClass <String[]> ] [-VendorClass <String[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Add-DhcpServerv4Policy cmdlet adds a new policy either at the server level or at the scope level. The policy name must be unique at the level, either server or specific scope, where the policy is added and should have at least one condition as specified by the CircuitId, ClientId, Fqdn, MACAddress, RelayAgent, RemoteId, SubscriberId, UserClass, or VendorClass parameter.

Parameters

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShell® background jobs, see about_Jobs.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<CimSession[]>

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.


Aliases

Session

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CircuitId<String[]>

Specifies the comparator to use and the values with which to compare the circuit id sub-option. The first element is the comparator, either EQ or NE, followed by a single value.

If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The value can again be followed by another comparator, either EQ or NE, which is followed by another value for comparison.

The input format for the value is a hexadecimal string with or without hyphen separation.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ClientId<String[]>

Specifies the comparator to use and the values with which to compare client identifier. The first element is the comparator, either EQ or NE, and subsequent elements are values.

If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The values can again be followed by another comparator, either EQ or NE, which is followed by another set of values for comparison.

The input format is a hexadecimal string with or without hyphen separation. For example: EQ, 00-11-22-33-44-55, AA-BB-CC-DD-EE*.

The output format is a hexadecimal string with hyphen separation.

The values that follow the EQ operator are treated as multiple assertions which are logically combined (OR’d).

The values that follow the NE operator are treated as multiple assertions which are logically differenced (AND’d).


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ComputerName<String>

Specifies the DNS name, or IPv4 or IPv6 address, of the target computer running the DHCP server service.


Aliases

Cn

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Condition<String>

Specifies the logical operator between conditions when multiple conditions are specified. The acceptable values for this parameter are: AND and OR.


Aliases

none

Required?

true

Position?

3

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Description<String>

Specifies the description string of the policy added.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Enabled<Boolean>

Specifies the enabled state of a policy.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Fqdn<String[]>

Specifies the comparator to use and the values with which to compare the fully qualified domain name (FQDN) in the client request. The first element is the comparator, EQ, NE, Isl, or Insl, and the subsequent elements are values. For the comparators Island Insl, use a blank value. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The values can again be followed by another comparator, EQ or NE, which is followed by another set of values.

The input format is a string. A trailing wildcard character can be present to indicate partial match.

The values that follow the EQ operator are treated as multiple assertions which are logically combined (OR’d).

The values that follow the NE operator are treated as multiple assertions which are logically differenced (AND’d).


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-LeaseDuration<TimeSpan>

Specifies the duration of the lease for clients that match the policy.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-MacAddress<String[]>

Specifies the comparator to use and the values with which to compare the MAC Address in the client request. The first element is the comparator, EQ or NE, and the subsequent elements are values. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as for comparison.

The values can again be followed by another comparator, EQ or NE, which is followed by another set of values.

The input format is a hexadecimal string with or without hyphen separation. A trailing wildcard character can be present to indicate partial match. For example: 00-1F-3B-7C-B7-89, 00-1F-3B-7C-B7-*, 001F3B7CB789. The output format is a hexadecimal string with hyphen separation.

The values that follow the EQ operator are treated as multiple assertions which are logically combined (OR’d).

The values that follow the NE operator are treated as multiple assertions which are logically differenced (AND’d).


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of the policy to be added.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ProcessingOrder<UInt16>

Specifies the order of this policy with regard to other policies in the scope or server. The DHCP server service processes the policies in the specified order when evaluating client requests.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-RelayAgent<String[]>

Specifies the comparator to use and values with which to compare the relay agent information. The first element is the comparator, EQ or NE, and subsequent elements are values. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The values can again be followed by another comparator, EQ or NE, which is followed by another set of values.

The input format is a hexadecimal string with or without hyphen separation.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-RemoteId<String[]>

Specifies the comparator to use and values with which to compare the remote ID sub-option. The first element is the comparator, EQ or NE, followed by a single value. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The value can again be followed by another comparator, EQ or NE, which is followed by another value.

The input format for the value is a hexadecimal string with or without hyphen separation.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ScopeId<IPAddress>

Specifies the scope identifier, in IPv4 address format, in which the policy is added.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-SubscriberId<String[]>

Specifies the comparator to use and the values with which to compare the subscriber ID sub-option. The first element is the comparator, EQ or NE, and followed by a single value. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The value can again be followed by another comparator, EQ or NE, which is followed by another value.

The input format is a hexadecimal string with or without hyphen separation.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UserClass<String[]>

Specifies the comparator to use and the user class values to compare with the user class field in the client request. The first element to be specified is the comparator, EQ or NE, and the subsequent elements are values. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The values can again be followed by another comparator, EQ or NE, which is followed by another set of values.

The values to be specified are the user class names which already exist on the server.

The values that follow the EQ operator are treated as multiple assertions which are logically combined (OR’d).

The values that follow the NE operator are treated as multiple assertions which are logically differenced (AND’d).


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-VendorClass<String[]>

Specifies the comparator to use and vendor class values to compare with the vendor class field in the client request. The first element is the comparator, EQ or NE, and the subsequent elements are values. If the last character in a value is an asterisk, then the subsequent characters are treated as wildcard characters for the comparison. If the first character in a value-element is an asterisk, the preceding characters are treated as wildcard characters for comparison.

The values can again be followed by another comparator, EQ or NE, which is followed by another set of values.

The values to be specified are the vendor class names which already exist on the server.

The values that follow the EQ operator are treated as multiple assertions which are logically combined (OR’d).

The values that follow the NE operator are treated as multiple assertions which are logically differenced (AND’d).


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Create a server level policy for virtual machine clients

This example creates a server level policy for virtual machine clients. The MAC addresses of Hyper-V virtual machines (00-15-5D) and VMWare virtual machines (00-05-69) are used as a condition in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "HyperVPolicy" -Condition OR -MacAddress EQ,00155D*,000569*

Example 2: Create a server level policy for non-virtual machine clients

This example creates a server level policy for non-virtual machine clients. The MAC address of Hyper-V virtual machines (00-15-5D) and VMware virtual machines (000569) is used as a negation condition in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "PhysicalComputersPolicy" -Condition OR -MacAddress NE,00155D*,000569*

Example 3: Create a scope level policy for virtual machine clients

This example creates a scope level policy for virtual machine clients inside the scope 10.10.10.0. The MAC addresses of Hyper-V virtual machines (00-15-5D) and VMware virtual machines (00-05-69) are used as a condition in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "VMPolicy" -ScopeId 10.10.10.0 -Condition OR -MacAddress EQ,00155D*,000569*

Example 4: Create a printer policy in a scope based on a vendor class

This example creates a printer policy inside the scope 10.10.10.0 based on the vendor class of printers. The vendor classes must be defined before they are used in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "PrinterPolicy" -ScopeId 10.10.10.0 -Condition OR -VendorClass EQ,"HP Printer","Xerox Printer"

Example 5: Create a printer policy in a scope based on a user class

This example creates a lab computers policy inside the scope 10.10.10.0 based on the user class. The user class must be defined before they are used in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "LabComputerPolicy" -ScopeId 10.10.10.0 -Condition OR -UserClass EQ,LabComputers

Example 6: Create a policy based on the relay agent information inside a scope

This example creates a policy based on the relay agent information (option 82) inside the scope 10.10.10.0. The DHCP relay agent must be configured to use the relay agent information option (option 82).


PS C:\> Add-DhcpServerv4Policy -Name "RelayAgentBasedPolicy" -ScopeId 10.10.10.0 -Condition OR -RelayAgent EQ,01030a0b0c02050000000123

Example 7: Create a policy by combining conditions based on a MAC address prefix and vendor class

This example creates a policy by combining conditions, using OR, based on MAC address prefix of HTC phone devices and vendor class of Android, inside the scope 10.10.10.0. The vendor class must be defined before it is used in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "DevicesPolicy" -ScopeId 10.10.10.0 -Condition OR -MacAddress EQ,F8DB7F* -VendorClass EQ,Android

Example 8: Create a server level policy for virtual machine clients, assign a processing order

This example creates a server level policy for virtual machine clients and assigns a processing order of 2 and creates the policy in a disabled state. The MAC addresses of Hyper-V virtual machines (00-15-5D) and VMWare virtual machines (00-05-69) are used as a condition in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "HyperVPolicy" -Condition OR -MacAddress EQ,00155D*,000569* -ProcessingOrder 2 -Enabled $False

Example 9: Create a policy by combining conditions based on a MAC address prefix and vendor class with lease duration

This example creates a policy by combining conditions, using OR, based on MAC address prefix of HTC phone devices and vendor class of Android, inside the scope 10.10.10.0. The vendor class must be defined before it is used in the policy. In addition, the command sets the lease duration for the clients to 10 days.


PS C:\> Add-DhcpServerv4Policy -Name "DevicesPolicy" -Condition OR -LeaseDuration 10 -MacAddress EQ,F8DB7F -ScopeId 10.10.10.0 -VendorClass "EQ","Android"

Example 10: Create a server level policy for workgroup joined clients

This example creates a server level policy for workgroup joined clients. The policy matches clients that have a single label FQDN in the conditions in the policy.


PS C:\> Add-DhcpServerv4Policy -Name "WorkgroupDevices" -Condition OR -Fqdn "Isl"

Example 11: Create a server level policy for clients that are not members of a domain

This example creates a server level policy for all foreign clients that are not members of the local domain contoso.com. The policy matches clients that have an FQDN that does not contain the value contoso.com.


PS C:\> Add-DhcpServerv4Policy -Name "ForeignDevices" -Condition OR -Fqdn NE,*.contoso.com

Related topics

Community Additions

ADD
Show: