What DNS records will be removed at next Scavenging script RRS feed

  • Question

  • Hi,

    I currently need to enable Zone Aging/Scavenging for a DNS Zone, But i want to make sure that only the correct stale records are removed.

    I was looking for a script that can send emails with the current Stale records that will be removed at next Scavenging.

    Is anyone familiar with any script that can help me with this issue?

    I wanted to try the script bellow but it looks like there is some issues importing the module as it most likley is no longer supported.


    Regards Oryp

    Thursday, February 22, 2018 12:02 PM

All replies

  • The file is still available on the link.


    Just download and unzip.


    Thursday, February 22, 2018 5:31 PM
  • I changed slight change in the script to work with Windows 2012 or Windows 2016 server (Powershell 4.0 or later)

    $smtpServer = "mail.contoso.com"

    $mailsender = "notification@contoso.com"

    $mailreceiver = "administrator@contoso.com"
    $DNSzone = "insead.test"
    $agedrecords = $null
    $Zone = Get-DnsServerZoneAging -Name $DNSzone -ComputerName <DNSServer>
    $aging = $zone.RefreshInterval + $zone.NoRefreshInterval
    $records = Get-DnsServerResourceRecord -ZoneName $DNSzone -ComputerName <DNSServer>
    foreach ($record in $records)

                    if (($record.timestamp -ne "Static") -and ((Get-Date).Addmilliseconds((-1)*$aging) -ge $record.timestamp))
                                    $agedrecords += $record.name + "`r`n"
    if ($agedrecords -ne $null)
    send-mailmessage -from $mailsender -to mailreceiver  -subject "[Warning] New DNS records are now aged and will be removed during the next Scavenging Cycle" -body $body -smtpServer $smtpServer -BodyAsHtml

    Regards, Vipin Vasudevan

    Thursday, February 22, 2018 6:28 PM
  • I gave up, Might be because i dont know how to use the scripts or how to import module but i never got it to work.

    But this one: https://gallery.technet.microsoft.com/scriptcenter/Fetch-DNS-scavenged-816b59ed#content

    Is working corretly and i can see what records was scavanged. 


    Tuesday, February 27, 2018 1:39 PM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 28, 2018 1:55 AM