Change owner dns record using powershell

Mohamed SAKHO 126 Reputation points
2021-10-05T16:52:58.913+00:00

Hello,

I would like to change many owner dns record in order to replace it by their object name computer using powershell.
Please does someone can help me, or have any script which can do this?
Or allow full control the computer name object for their each dns record via powershell.
Thank you by advance.

Windows for business Windows Client for IT Pros Networking Network connectivity and file sharing
Windows for business Windows Server User experience PowerShell
Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. Mohamed SAKHO 126 Reputation points
    2021-10-11T15:06:34.003+00:00

    Hello,

    This script mays works but I mean it needs an external module (ADDnsPartition).
    I found a script to solve my issue.

    https://learn.microsoft.com/en-us/answers/questions/355589/script-to-change-permissions-on-dns-records.html?sort=votes

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2021-10-05T18:47:21.503+00:00

    Are you trying to fix inconsistent permissions so dynamic DNS updates are allowed to be made by the computer account?

    Here's one: Resolve-DdnsRecordPermissionProblem.ps1

    0 comments No comments

  2. Limitless Technology 39,916 Reputation points
    2021-10-06T14:45:18.303+00:00

    Hello,

    additional clarifying question would be if you are trying to remove from the DNS lists some current computer owner so you see the sid info as the current owner? And you like to replace it to computer_name.

    Import-Module D:\Powershell\DNS\DnsShell
    Import-Module ActiveDirectory
    Add-PSSnapin Quest.ActiveRoles.ADManagement

    Retrieve records

    $servers = get-content D:\Powershell\Scripts\DNSRECORDS.txt
    $newarray = @()
    foreach ($computer in $servers) {
    Get-ADDnsPartition | Get-ADDnsRecord | Where-Object {$.Name -eq $Computer} | % {
    $RecordName = $
    .Name
    $RecordName = "GTLAW\$RecordName" + '$'
    $RecordDN = (Get-ADObject –Identity $.ObjectGUID).DistinguishedName
    $Owner = (Get-Acl -Path "ActiveDirectory:://RootDSE/$RecordDN").Owner
    If ($Owner -eq "$RecordName") {
    Write-Host 'Good |' $
    .Name '|' $Owner
    } Else {
    Write-Host 'Bad |' $.Name '|' $RecordName $Owner
    $AdACL = get-ACL ("AD:\" + $RecordDN)
    $ADobject = New-Object System.Security.Principal.NTAccount($
    .NAME + "$")
    $sid = $ADobject.Translate([System.Security.Principal.SecurityIdentifier])
    $AdACL.SetOwner($sid)
    set-acl -path ("AD:\" + $RecordDN) -AclObject $AdACL
    }
    }
    }


    If the reply is helpful, please Upvote and Accept as answer

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.