Search code examples
powershelldnswindows-server

Enabling DNS server scavenging using PowerShell


I am trying to enable scavenging on a Windows Server 2022 DNS server using PowerShell. Aging at the zone level has been configured using Set-DnsServerZoneAging, but I am unable to enable scavenging at the server level using Set-DnsServerScavenging:

$timeSpan = New-TimeSpan -Days 7
Set-DnsServerScavenging `
  -ScavengingState $true `
  -RefreshInterval $timeSpan `
  -NoRefreshInterval $timeSpan

Is it possible to enable scavenging at the server level using PowerShell as per the image below?

enter image description here


Solution

  • The checkbox you indicated is enabled via the Set-DnsServerScavenging command.

    Try running it as follows:

    Set-DnsServerScavenging `
        -ScavengingState $true `
        -RefreshInterval $timeSpan `
        -NoRefreshInterval $timeSpan `
        -ScavengingInterval $timeSpan
    

    That last param is the key. If ScavengingInterval is not set, then the checkbox remains in its default state (unchecked).