Add-DhcpServerv4Policy

Add-DhcpServerv4Policy is accessible with the help of DHCPServer module. To configure DHCPServer, go through this link.

Synopsis

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

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.

Type:SwitchParameter
Position:Named
Default value:None
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-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Type:CimSession[]
Aliases:Session
Position:Named
Default value:None
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 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.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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-0C-29-00-E0-6B, 00-0C-29-00-E0*.

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).

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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
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 and OR.

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

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-Description

Specifies the description string of the policy added.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Enabled

Specifies the enabled state of a policy.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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).

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

-LeaseDuration

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

Type:TimeSpan
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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-0C-29-00-E0-6B, 00-0C-29-00-E0*, 000C2900E06B. 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).

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

-Name

Specifies the name of the policy to be added.

Type:String
Position:1
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.

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

-ProcessingOrder

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.

Type:UInt16
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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.

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

-ScopeId

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

Type:IPAddress
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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
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 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).

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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 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).

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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
Accept pipeline input:False
Accept wildcard characters:False

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>]

—————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 WorkgroupDevices -Condition OR -Fqdn slave
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 3—————
PS C:>Add-DhcpServerv4Policy -Name PrinterPolicy1 -ScopeId 192.168.10.0 -Condition OR -VendorClass EQ,”Elipson Printers”,”HP Printers”
This example creates a printer policy inside the scope 192.168.10.0 based on the vendor class of printers. The vendor classes need to be defined before being used in the policy.

—————EXAMPLE 4—————
PS C:>Add-DhcpServerv4Policy -Name LabComputerPolicy -ScopeId 192.168.11.0 -Condition OR -UserClass EQ,devComputers
This example creates a lab computers policy inside the scope 192.168.11.0 based on the user class. The user class needs to be defined before being used in the policy.

—————EXAMPLE 5—————
PS C:>Add-DhcpServerv4Policy -Name ForeignDevices -Condition OR -Fqdn NE,*.TOSSolution.com
This example creates a server level policy for all foreign clients that are not members of the local domain TOSSolution.com. The policy matches clients that have an FQDN that does not contain the value TOSSolution.com.

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command Add-DhcpServerv4Policy

Get-Command Add-DhcpServerv4Policy powershell script command cmdlet dhcp

You can also read about

  • Add-DhcpServerv4PolicyIPRange
  • Get-DhcpServerv4Policy
  • Get-DhcpServerv4PolicyIPRange
  • Remove-DhcpServerv4Policy
  • Remove-DhcpServerv4PolicyIPRange
  • Set-DhcpServerv4Policy

To know more PowerShell cmdlets(Commands) on DHCPServer click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Leave a Reply

Your email address will not be published. Required fields are marked *