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 10.11.11.0 | Remove-DhcpServerv4Reservation -ComputerName zz #; Get-DhcpServerv4Filter | Remove-DhcpServerv4Filter
to start clean each time, one line per scope and then, per reservation:
Add-DhcpServerv4Reservation -ScopeId 10.11.11.0 -IPAddress 10.11.11.140 -ClientId "80-2A-A8-3A-0B-07" -Name "10000140.domain.tld" ; Set-DhcpServerv4OptionValue -ReservedIP 10.11.11.140 -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.
- 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.