Windows – Converting dynamic DNS records to static

domain-name-systemwindows

In preparation to enable DNS Aging/Scavenging, one point brought up to us are our printers (have a little over a 1000) and having DNS failing to update. All Zones are Active Directory-Integrated. I am trying to figure out the best approach to set these to a static record. All the printers start with the same prefix for the name in DNS (xxx…102, xxx…103, xxx…104). I am pondering two options.

A:) Convert all the printer records to static records without having to manually edit each record. Is there a way I can do a filter for the printer prefix and convert them to static records from DNSCMD?

B:) Export all printer records that match a filter with the printer prefix and then import them as a static record?

Guidance would be appreciated for either of these options or another viable alternative. Any other advice for enabling DNS Aging/Scavenging for a large enterprise would be of course welcomed.

Thanks.

Best Answer

@Massimo is partially correct, in that you can use Set-DnsServerResourceRecord for this, but you cannot directly set the timestamp as that property is considered read only. Instead, any change you make will result in the record becoming static.

Here's a sample of how you might go about that:

$dnsServer = 'MyDC01'
$zone = 'contoso.com'
$records = Get-DnsServerResourceRecord -ComputerName $dnsServer -ZoneName $zone -RRType A | Where-Object { $_.HostName -like 'printer*' }

$records | ForEach-Object {
    Set-DnsServerResourceRecord -OldInputObject $_ -NewInputObject $_ -ComputerName $dnsServer -ZoneName $zone
}

This should be non-destructive since the input and output objects are the same, but be careful, have backups!

Regarding Scavenging

If your printer's records are already dynamic (perhaps because they are configured via DHCP and DHCP is refreshing them), then you probably should not make them static. If DHCP and dynamic DNS are working properly, then the dates will update, and scavenging won't hurt them.

If the printers are DHCP but the timestamps are not updating, then you should figure out why and resolve the problem before enabling scavenging.

If you must make these static, DHCP should be configured for those scopes or for those individual reservations not to dynamically update DNS.

Note about timestamps

You must enable scavenging on the AD integrated zones before timestamps will replicate. If it looks like the dates are all wrong and inconsistent you may be running into this. Enabling scavenging on the zone does not scavenge records (that setting is on the server). I had scavenging enabled on the zones for 2 months before I actually set scavenging to run, so that I could be sure the timestamps were consistent and being updated.