Reservertion for DHCP options not found via PowerShell

Vita 76 Reputation points

Being the least annoying, quicker and portable way to manage DHCP reservations on Windows I started doing it through a giant PowerShell script. Instead of doing it importing a CSV it does on a cmdlet-by-cmdlet basis. It had been working well until today when I keep getting these errors:

The full file would be a repetition of first:

Get-DhcpServerv4Scope -ComputerName zz -ScopeId | Remove-DhcpServerv4Reservation -ComputerName zz #; Get-DhcpServerv4Filter | Remove-DhcpServerv4Filter

to start clean each time, one line per scope and then, per reservation:

Add-DhcpServerv4Reservation -ScopeId -IPAddress -ClientId "80-2A-A8-3A-0B-07" -Name "10000140.domain.tld"         ; Set-DhcpServerv4OptionValue -ReservedIP -OptionId 12 -Value "hostname.domain.tld"


All the extra white space is to make it legible in the text editor. The file is in a network share (hence the A: drive) so it's not unusual to edit it in non-Windows systems and I think at some point it might have changed encoding, so I discovered some options where stuck with others or with the cmdlet itself. I replaced all of those (invisible) characters and tested again saving the file in ANSI and UTF-8 but it won't work.

Even after creating new files it doesn't work anymore. Entering the commands directly in PowerShell does still work, even in succession:

.…but it's just as cumbersome af the other management options.

What could I do to fix it? Is it fixable or should I just start looking into new DHCP servers? A baremetal Fedora Server was just deployed today, it might be perfect timing. The only other baremetal server was the DHCP server and it's only bare metal because it's the DHCP server.

Almost forgot,

  • it's Window Server 2016, it's a Domain Controller (it just made sense given its privileged situation)
  • The server holds FSMOs, not all
  • AD replication is OK
  • DHCP allocation is OK
  • It's a single DHCP server, not part of a failover group
  • The other two DCs are WS2019 which has made serious damage in the past regarding replication. Currently they seem to be behaving though.
  • Given the script wipes all the reservations from all the scopes each run, the fact that they are there means it's somehow working, at least until the DHCP option is added where it seems to fail.


Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,272 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 43,926 Reputation points

    Why do you specify a computer name for the Get-DhcpServerV4Scope and Remove-dhcpServerV4Reservation, but not for the Add-DhcpServerV4Reservation and Set-DhcpServerV4OptionValue?

    If the Add reservation works, does the Set option value work if you pipe the results from the Add reservation into the Set option value (removing the "-reserverip" of course)?

    0 comments No comments