none
Remove-DnsServerResourceRecord : Failed to get RRS feed

  • Question

  • Hi all, I have a script that should be deleting PTR records, but it is sending back the error message:

    "Remove-DnsServerResourceRecord : Failed to get r-temp.eng.com. record in 144.6.10.in-addr.arpa zone on corp-dns server."

    Here is the script:

    $zones=0
    $zonecount=0
    $countz=0
    $counth=0
    $ipform=0
    $OutFile = "C:\Test\ReverseLogFile.csv"

    $zones=Get-WMIObject -computername "corp-dns" -Namespace Root\MicrosoftDNS -Class "MicrosoftDNS_Zone" | ? { $_.ContainerName -Notlike '..RootHints' -And $_.ContainerName -NotLike '..Cache' -notlike !$_.Reverse } | Select Name


    foreach ($zone in $zones){
        $zonecount=$zones[$countz]
        $zonename=$zonecount.name
        $ipget=gwmi -Class MicrosoftDNS_PTRType -NameSpace Root\MicrosoftDNS -ComputerName corp-dns  -Filter "DomainName = '$zonename' AND TimeStamp = 0" | Select-Object -property Ownername, RecordData, Timestamp   
        $ipnames=$ipget
        $counth=0
    foreach ($ipname in $ipnames){
        $iparray=$ipget[$counth]
        $ipaddy=$iparray.ownername
        $name=$iparray.recorddata
        $ipsplit=$ipaddy.split(".")
        $ipform=$ipsplit[3]+"."+$ipsplit[2]+"."+$ipsplit[1]+"."+$ipsplit[0]
        #write-host $ipform "ipform"
        if (Test-Connection -ComputerName $ipform -count 2 -ErrorAction SilentlyContinue){
                Write-Host "$ipform, $name, Up and Running"
                Write-Output "$ipform, $name, Up and Running" | Out-File $OutFile -Append
                $counth=$counth+1
                Write-Host $counth, "counth"                                                                                   }
            else{
                Write-Host "$ipform, $name, Host down - deleting PTR Record"
                Write-Output "$ipform, $name, Host down - A Record deleted." | Out-File $OutFile -Append
                Remove-DnsServerResourceRecord -zonename "$zonename" -ComputerName corp-dns -RRType PTR -Name $name -Force
                $counth=$counth+1
                }
        #$counth=$counth+1
        }
       $countz=$countz+1
        }
       

    Can anyone point out why I keep getting this error?  TIA

    • Moved by Bill_Stewart Thursday, January 25, 2018 9:57 PM This is not "fix/debug/rewrite my script for me" forum
    Tuesday, September 5, 2017 6:59 PM

All replies