Set-DhcpServerv4OptionValue
Sets an IPv4 option value at the server, scope, or reservation level.
Syntax
OptionIds (Default)
Set-DhcpServerv4OptionValue
[[-ScopeId] <IPAddress>]
[-Value] <String[]>
[-OptionId] <UInt32>
[-PolicyName <String>]
[-PassThru]
[-Force]
[-ReservedIP <IPAddress>]
[-UserClass <String>]
[-ComputerName <String>]
[-VendorClass <String>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
CommonOptions
Set-DhcpServerv4OptionValue
[[-ScopeId] <IPAddress>]
[-PolicyName <String>]
[-PassThru]
[-Force]
[-DnsDomain <String>]
[-DnsServer <IPAddress[]>]
[-ReservedIP <IPAddress>]
[-Router <IPAddress[]>]
[-UserClass <String>]
[-WinsServer <IPAddress[]>]
[-Wpad <String>]
[-ComputerName <String>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Set-DhcpServerv4OptionValue cmdlet sets an IPv4 option value at the server, scope, or reservation level. The definition for the option must already exist. This cmdlet fails if the option definition does not occur in the Dynamic Host Configuration Protocol (DHCP) server service.
If you specify only the ReservedIP parameter, the option values are set at the reservation level. If you specify only the ScopeId parameter, the option values are set at the scope level.
If you specify neither the ScopeId nor ReservedIP parameter, the option values are set at the server level. If you specify the VendorClass parameter, the option value is set for that vendor class.
If you specify the UserClass parameter, the option value is set for that user class.
If you specify the PolicyName parameter, the option values are set for that policy. The UserClass and PolicyName parameters cannot both be specified. The ScopeId and ReservedIP parameters cannot both be specified.
The PolicyName and ReservedIP parameters cannot both be specified.
The option values for policies can only be set for a DHCP server service that runs on Windows Server® 2012 and later versions of the Windows operating system. Setting user class options for a DHCP server service that runs on Windows Server 2012 and later versions of the Windows operating creates of a policy with the policy name set to the name of the user class. For a DHCP server service that runs on firstref_server_7 or earlier, only option values based on the user class can be set.
To set options based on legacy user classes, the UserClass parameter must be specified.
Examples
Example 1: Set server level option values
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -DnsServer 192.168.1.2 -WinsServer 192.168.1.3 -DnsDomain "contoso.com" -Router 192.168.1.1 -Wpad "http://proxy.contoso.com/wpad.dat"
This example sets the server level option values for DNS server, WINS server, DNS domain, router, and WPAD.
Example 2: Set option values for a scope
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -DnsServer 192.168.1.2 -WinsServer 192.168.1.3 -DnsDomain "contoso.com" -Router 192.168.1.1 -Wpad "http://proxy.contoso.com/wpad.dat"
This example sets the option values for DNS server, WINS server, DNS domain, router, and WPAD for scope 10.10.10.0.
Example 3: Set option values for an address
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ReservedIP 10.10.10.5 -DnsServer 192.168.1.2 -WinsServer 192.168.1.3 -DnsDomain "contoso.com" -Router 192.168.1.1 -Wpad "http://proxy.contoso.com/wpad.dat"
This example sets the option values for DNS server, WINS server, DNS domain, router, and WPAD for reserved IP address 10.10.10.5.
Example 4: Set option values for a policy
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -PolicyName "LabComputers" -DnsServer 192.168.1.2 -WinsServer 192.168.1.3 -DnsDomain "contoso.com" -Router 192.168.1.1 -Wpad "http://proxy.contoso.com/wpad.dat"
This example sets the option values for DNS server, WINS server, DNS domain, router, and WPAD for policy named LabComputers in the scope 10.10.10.0.
Example 5: Set service-wide option value for DNS server
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -OptionId 6 -Value "192.168.1.1"
This example sets the server-wide DHCPv4 option value for option ID 6, or DNS server.
Example 6: Set option value for DNS server for a scope
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -OptionId 6 -Value "192.168.1.1"
This example sets the DHCPv4 option value for option ID 6, or DNS server, for the scope 10.10.10.0.
Example 7: Set option value for DNS server for a reservation
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ReservedIP 10.10.10.5 -OptionId 6 -Value "192.168.1.1"
This example sets the DHCPv4 option value for option ID 6, or DNS server, for the specified reservation.
Example 8: Set a vendor class specific option value
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -VendorClass "MSUCClient" -OptionId 5 -Value ([System.Text.Encoding]::ASCII.GetBytes("/CertProv/CertProvisioningService.svc"))
This example sets the vendor class specific DHCPv4 option value for option ID 5 on the specified scope for the specified vendor class named MSUCClient.
Example 9: Set option value for DNS server for a policy
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -PolicyName "PrinterPolicy" -OptionId 6 -Value "192.168.1.10"
This example sets the DHCPv4 option value for option ID 6, or DNS server, on the specified scope for the specified policy.
Example 10: Set a user class specific option value for DNS server
PS C:\> Set-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0 -UserClass "LabComputer" -OptionId 6 -Value "192.168.1.10"
This example sets the user class specific DHCPv4 option value for option ID 6, or DNS server, on the specified scope for the specified user class.
Example 11: Set a vendor class specific option value for a scope
PS C:\> Set-DhcpServerv4OptionValue -ScopeId 10.10.10.0 -OptionId 43 -Value "241","08","33","255","132","10","33","255","133"
This example sets the vendor class specific DHCPv4 option value for option ID 43, or embedded vendor-specific options, on the specified scope.
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.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | 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.
Parameter properties
Type: | CimSession[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Session |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ComputerName
Specifies the DNS name, or IPv4 or IPv6 address, of the target computer that runs the DHCP server service.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Cn |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DnsDomain
Specifies the value for the DNS domain option.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
CommonOptions
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-DnsServer
Specifies one or more values for the DNS server option, in the IPv4 address format.
Parameter properties
Type: | IPAddress[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
CommonOptions
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Force
Specifies that the DNS server validation is skipped. This parameter is only applicable if the DnsServer parameter is specified.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-OptionId
Specifies the numeric identifier (ID) of the option for which one or more values are set.
Parameter properties
Type: | UInt32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
OptionIds
Position: | 1 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-PassThru
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-PolicyName
Specifies the name of the policy for which one or more option values are set.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-ReservedIP
Specifies the IPv4 address of the reservation for which one or more option values are set.
Parameter properties
Type: | IPAddress |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | IPAddress |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Router
Specifies one or more values for the router or default gateway option, in IPv4 address format.
Parameter properties
Type: | IPAddress[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
CommonOptions
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-ScopeId
Specifies the scope ID, in IPv4 address format for which one or more option values are set.
Parameter properties
Type: | IPAddress |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | 3 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | 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.
Parameter properties
Type: | Int32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-UserClass
Sets the option value for the specified user class.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Value
Specifies one or more values to be set for the option. Use the following formats:
- Byte, Word, DWord, DWordDword. Specify as decimal or hexadecimal strings.
- IPAddress, IPv6Address. Specify as strings.
- String. Specify as strings.
- BinaryData, EncapsulatedData. Specify as hexadecimal strings.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
OptionIds
Position: | 2 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-VendorClass
Sets the option value for the specified vendor class.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
OptionIds
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-WinsServer
Specifies the values for the WINS server option, in IPv4 address format.
Parameter properties
Type: | IPAddress[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
CommonOptions
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Wpad
Specifies the value for the web proxy auto detection option. The value for this option is specified as a URL.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
CommonOptions
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
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.