We are using DHCP-Reservation to provide an IP-adress to our clients. Additional we use the DHCP-Option 12 to handle the Hostname of the client.
The DHCP-reservation (including the option12) were set within a powershell script to decrease the manual tasks.
We noticed, that the DHCP-Option 12 of IP-Reservation (which was set with the command "Set-DhcpServerv4OptionValue") will be resetted after a restart of the DHCP-Server.
Note: when you do this step manually within the GUI, the problem does not occure.
Summarized: setting the option 12 to a DHCP-Reservation with command "Set-DhcpServerv4OptionValue", will be resetted after restarting the DHCP-Services.
Can anyone provide me a workaround or does anyone have a idea how I can solve the issue?
Attached you can find a short Powershell-Snippet which you can use to reproduce the problem:
Blockquote
#Ensure that you have a IP-Scope with 192.168.10.0
$ipscope = "192.168.10.0"
$ipscope_start = "192.168.10.1"
$ipscope_end = "192.168.10.254"
$ipscope_subnetmask = "255.255.255.0"
[ipaddress]$ip = "192.168.10.18" #Mention your IP-Adress you want to test
$DHCPServer = "TEMPLATE_W2K16" #Mention the Servername of your testserverAdd-DhcpServerv4Scope -ComputerName $DHCPServer -StartRange $ipscope_start -EndRange $ipscope_end -Name $ipscope -SubnetMask $ipscope_subnetmask
Add-DhcpServerv4Reservation -ComputerName $DHCPServer -ScopeId $ipscope -IPAddress $ip -ClientId "11-22-33-44-55-66" -Name "Initialname"For($i=0; $i -le 5;$i++)
{
$reservationname = "Name$i"
Set-DhcpServerv4Reservation -IpAddress $ip -ClientId 11-22-33-44-55-66 -Name $reservationname -Description $reservationname -Type Dhcp -ComputerName $DHCPServer
Set-DhcpServerv4OptionValue -ReservedIP $ip -OptionId 12 -Value $reservationname -ComputerName $DHCPServer
$OptionValue1 = Get-DhcpServerv4OptionValue -ReservedIP $Ip -ComputerName $DHCPServer
Write-host "Current Option: $($OptionValue1.Value)"
Read-host "Restart DHCP-Service?"
Restart-Service DHCPServer
sleep -Seconds 5
$OptionValue2 = Get-DhcpServerv4OptionValue -ReservedIP $Ip -ComputerName $DHCPServer
Write-Host "Option12 we want to set: $reservationname"
Write-host "Option12 after restart: $($OptionValue2.Value)"
Read-host "Next try?"
}