Change owner dns record using powershell

Mohamed SAKHO 116 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 Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,212 questions
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.
1,023 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.
5,390 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 45,096 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,406 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