Change owner dns record using powershell

Mohamed SAKHO 96 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 DHCP
Windows DHCP
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.DHCP: Dynamic Host Configuration Protocol (DHCP). A communications protocol that lets network administrators manage centrally and automate the assignment of Internet Protocol (IP) addresses in an organization's network.
926 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
8,255 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,628 questions
No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 35,191 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

    No comments

  2. Limitless Technology 37,351 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

    No comments