Add-DhcpServerv4Policy

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

Syntax

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

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.

Examples

EXAMPLE 1

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

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

EXAMPLE 2

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

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

EXAMPLE 3

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

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

EXAMPLE 4

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

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

EXAMPLE 5

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

This example creates a lab computers policy inside the scope 10.10.10.0 based on the user class. The user class needs to be defined before being used in the policy.

EXAMPLE 6

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

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

EXAMPLE 7

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

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 needs to be defined before being used in the policy.

EXAMPLE 8

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

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

EXAMPLE 9

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

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 needs to be defined before being used in the policy. In addition, the command sets the lease duration for the clients to 10 days.

EXAMPLE 10

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

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.

EXAMPLE 11

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

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.

Parameters

-AsJob

ps_cimcommon_asjob

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-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-CimSessionhttp://go.microsoft.com/fwlink/p/?LinkId=227967 or Get-CimSessionhttp://go.microsoft.com/fwlink/p/?LinkId=227966 cmdlet. The default is the current session on the local computer.

Type:CimSession[]
Aliases:Session
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CircuitId

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 wild cards 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.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ClientId

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 wild cards 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 following the EQ operator will be treated as multiple assertions which are logically combined (OR'd).

The values following the NE operator will be treated as multiple assertions which are logically differenced (AND'd).

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ComputerName

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

Type:String
Aliases:Cn
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Condition

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

Type:String
Accepted values:And, Or
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Description

Specifies the description string of the policy being added.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Enabled

Specifies the enabled state of a policy. The acceptable values for this parameter are: True or False.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Fqdn

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 wild cards 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 following the EQ operator are treated as multiple assertions which are logically combined (OR'd).

The values following the NE operator are treated as multiple assertions which are logically differenced (AND'd).

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-LeaseDuration

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

Type:TimeSpan
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-MacAddress

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 wild cards 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 following the EQ operator will be treated as multiple assertions which are logically combined (OR'd).

The values following the NE operator will be treated as multiple assertions which are logically differenced (AND'd).

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of the policy to be added.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProcessingOrder

Specifies the order of this policy with respect to other policies in the scope or server. The DHCP server service will process the policies in the specified order while evaluating client requests.

Type:UInt16
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-RelayAgent

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 wild cards 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.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-RemoteId

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 wild cards 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.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ScopeId

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

Type:IPAddress
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SubscriberId

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 wild cards 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.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ThrottleLimit

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.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UserClass

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 wild cards 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 following the EQ operator are treated as multiple assertions which are logically combined (OR'd).

The values following the NE operator are treated as multiple assertions which are logically differenced (AND'd).

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VendorClass

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 wild cards 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 following the EQ operator are treated as multiple assertions which are logically combined (OR'd).

The values following the NE operator are treated as multiple assertions which are logically differenced (AND'd).

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

CimInstance

The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

CimInstance

The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

Outputs

CimInstance

The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.